Skip to content

Comments

fix Issue 15374 - Move genCmain into Compiler struct.#7534

Merged
dlang-bot merged 2 commits intodlang:masterfrom
ibuclaw:issue15374
Oct 1, 2018
Merged

fix Issue 15374 - Move genCmain into Compiler struct.#7534
dlang-bot merged 2 commits intodlang:masterfrom
ibuclaw:issue15374

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Dec 27, 2017

Probably a good time to think about what to do with entrypoint and rootHasMain. Keep as top-level vars? Or move into Global.

@dlang-bot
Copy link
Contributor

dlang-bot commented Dec 27, 2017

Thanks for your pull request, @ibuclaw!

Bugzilla references

Auto-close Bugzilla Severity Description
15374 blocker [internal] Nothing should import ddmd.mars

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

To target stable perform these two steps:

  1. Rebase your branch to upstream/stable:
git rebase --onto upstream/stable upstream/master
  1. Change the base branch of your PR to stable

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#7534"

@wilzbach
Copy link
Contributor

Regarding:

CC="c++" /home/braddr/sandbox/at-client/release-build/install/freebsd/bin32/dmd -lib -of../generated/freebsd/release/32/lexer.a -m32 -J../generated/freebsd/release/32 -L-lstdc++ -version=MARS  -w -de -O -release -inline dmd/console.d dmd/entity.d dmd/errors.d dmd/globals.d dmd/id.d dmd/identifier.d dmd/lexer.d dmd/tokens.d dmd/utf.d dmd/root/array.d dmd/root/ctfloat.d dmd/root/file.d dmd/root/filename.d dmd/root/outbuffer.d dmd/root/port.d dmd/root/rmem.d dmd/root/rootobject.d dmd/root/stringtable.d dmd/root/hash.d
dmd/doc.d(356): Error: file "default_ddoc_theme.ddoc" cannot be found or not in a path specified with -J
posix.mak:445: recipe for target '../generated/freebsd/release/32/lexer.a' failed

The other targets do seem to have -J$G -J../res (instead of just -J$G), but the error suggests that now doc.d is imported.

@ibuclaw
Copy link
Member Author

ibuclaw commented Dec 27, 2017

I'm not sure what that has to do with this PR.

It built locally just fine for me.

@wilzbach
Copy link
Contributor

It built locally just fine for me.

Maybe you didn't clean your build directory. I can reproduce the failure locally and as said this will fix it:

diff --git a/src/posix.mak b/src/posix.mak
index a025bb42f..9a42370ab 100644
--- a/src/posix.mak
+++ b/src/posix.mak
@@ -442,7 +442,7 @@ $G/backend.a: $(G_OBJS) $(SRC_MAKE)
 	$(AR) rcs $@ $(G_OBJS)
 
 $G/lexer.a: $(LEXER_SRCS) $(LEXER_ROOT) $(HOST_DMD_PATH) $(SRC_MAKE)
-	CC="$(HOST_CXX)" $(HOST_DMD_RUN) -lib -of$@ $(MODEL_FLAG) -J$G -L-lstdc++ $(DFLAGS) $(LEXER_SRCS) $(LEXER_ROOT)
+	CC="$(HOST_CXX)" $(HOST_DMD_RUN) -lib -of$@ $(MODEL_FLAG) -J$G -J../res -L-lstdc++ $(DFLAGS) $(LEXER_SRCS) $(LEXER_ROOT)
 
 $G/dmd_frontend: $(FRONT_SRCS) $D/gluelayer.d $(ROOT_SRCS) $G/newdelete.o $G/lexer.a $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
 	CC="$(HOST_CXX)" $(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J../res -L-lstdc++ $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^) -version=NoBackend

But I'm still not sure why your changes are leading to the lexer importing doc.d

@wilzbach
Copy link
Contributor

Problem is due to globals.d now importing compiler.d:

> ag "import dmd.compiler"
dmd/mars.d
30:import dmd.compiler;

dmd/globals.d
22:import dmd.compiler;

dmd/dsymbolsem.d
30:import dmd.compiler;

@ibuclaw
Copy link
Member Author

ibuclaw commented Dec 31, 2017

Rebased.

Copy link
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just fix the build errors.

import dmd.id;
import dmd.identifier;
import dmd.parse;
import dmd.semantic;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import dmd.semantic2 and dmd.semantic3 instead.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jan 6, 2018

object.Error@src/rt/minfo.d(371): Cyclic dependency between module dmd.lexer and dmd.traits
dmd.lexer* ->
dmd.globals ->
dmd.compiler ->
dmd.dsymbolsem ->
dmd.expressionsem ->
dmd.traits* ->
dmd.dsymbol ->
dmd.lexer*

😨

@jacob-carlborg
Copy link
Contributor

Perhaps the module constructor in lexer.d can be replaced with a CTFE function.

@wilzbach
Copy link
Contributor

wilzbach commented Jan 7, 2018

Perhaps the module constructor in lexer.d can be replaced with a CTFE function.

Yes, let's kill the module constructor with CTFE 🔥
-> #7623

@ibuclaw
Copy link
Member Author

ibuclaw commented Jan 7, 2018

Regarding the requirement of -J../res, this should not flag up if all imports are nested in functions.

@wilzbach
Copy link
Contributor

wilzbach commented Jan 7, 2018

Regarding the requirement of -J../res, this should not flag up if all imports are nested in functions.

DMD only does lazy imports for templates. Anyhow we shouldn't need to add -J ../res because that means that parser.a library depends on doc.d, which it didn't before this PR.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jan 7, 2018

What about the (currently unused) dmd.frontend? initDMD() sure sounds like a tempting place to initialize dmd-specific global fields.

@jacob-carlborg
Copy link
Contributor

jacob-carlborg commented Jan 7, 2018

initDMD is intended to be used when using the DMD library (Dub package).

@wilzbach
Copy link
Contributor

wilzbach commented Jan 7, 2018

initDMD is intended to be used when using the DMD library (Dub package).

Yep and we want to be able to use Phobos for that to provide nice high-level wrappers.

Anyhow we shouldn't need to add -J ../res because that means that parser.a library depends on doc.d, which it didn't before this PR.

OTOH considering how much pain lexer.a is bringing us - compared to the little gain (people will use the DUB package anyways, I doubt anyone will use lexer.a as generated by the Makefile) - you might also want to ignore my statement.

@jacob-carlborg
Copy link
Contributor

OTOH considering how much pain lexer.a is bringing us - compared to the little gain (people will use the DUB package anyways, I doubt anyone will use lexer.a as generated by the Makefile

I thought that was removed.

@wilzbach
Copy link
Contributor

wilzbach commented Jan 7, 2018

@RazvanN7
Copy link
Contributor

If globals.d imports compiler.d then compiler.d should contain only files present in the parser library, otherwise we will end up adding semantic dependencies for the parser library.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jan 30, 2018

Indeed, however there are a couple settings that should be set up outside of global module, notably the vendor and version string. Both of which are used by the parser.

Perhaps now there's a frontend module I can dissolve global._init() and move the remaining field initialization to more relevant places.

@ibuclaw
Copy link
Member Author

ibuclaw commented Oct 1, 2018

Rebased.

@ibuclaw
Copy link
Member Author

ibuclaw commented Oct 1, 2018

Rebased again, reapplying auto-merge.

@dlang-bot dlang-bot merged commit 11573d2 into dlang:master Oct 1, 2018
@ibuclaw ibuclaw deleted the issue15374 branch October 2, 2018 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants