Skip to content

Cleanup DMD as a library build files#7418

Merged
andralex merged 2 commits intodlang:masterfrom
wilzbach:cleanup-dmd-as-a-library
Dec 12, 2017
Merged

Cleanup DMD as a library build files#7418
andralex merged 2 commits intodlang:masterfrom
wilzbach:cleanup-dmd-as-a-library

Conversation

@wilzbach
Copy link
Contributor

A few things I found when working on #7415 and looking at the examples for DMD as a library:

  • Allow them to be directly executable (via the DMD DUB package)
  • Add a wild rule to avoid redundant logic
  • Remove irrelevant link flags like -L-lstd++
  • Move example binaries to the generated directory
  • Start building the examples on auto-tester (Posix-only for now) IMPORTANT: the examples are currently not part of our CI
  • Make Phobos path in impvisitor example more robust
  • Build the examples with the current, generated DMD binary (separate commit, if controversial)

I think this is the coolest bit is that the examples for having DMD as a library are executable via DUB. This also means that we could drop them from the posix.mak and win32.mak altogether, could move them to a different directory (e.g. the test suite or samples) and don't need to worry about writing any cross-platform Makefiles as DUB takes care of this.

CC @RazvanN7

- Allow them to be directly executable (via the DMD DUB package)
- Add a wild rule to avoid redundant logic
- Remove irrelevant link flags like `-L-lstd++`
- Move example binaries to the generated directory
- Start building the examples on auto-tester (Posix-only for now)
- Make Phobos path in impvisitor example more robust
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

PARSER_SRCS=$(addsuffix .d, $(addprefix $D/,parse astbase parsetimevisitor transitivevisitor permissivevisitor strictvisitor))

$G/parser.a: $(PARSER_SRCS) $(LEXER_SRCS) $(ROOT_SRCS) $G/dmd $(SRC_MAKE)
CC="$(HOST_CXX)" $G/dmd -lib -of$@ $(MODEL_FLAG) -L-lstdc++ -J$G $(DFLAGS) $(PARSER_SRCS) $(LEXER_SRCS) $(ROOT_SRCS)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: the existing parser.a target is only needed to build the examples

@wilzbach wilzbach force-pushed the cleanup-dmd-as-a-library branch from c43e76f to 47e6b5f Compare December 11, 2017 03:58
@WalterBright
Copy link
Member

A more general issue - with every PR, src/ddmd/posix.mak gets ever more convoluted and impenetrable. It's so awful, another makefile, src/posix.mak, was spawned to drive it, and that one over time got successively more convoluted and impenetrable.

I suspect there is a nice makefile in there somewhere trying to get out.

@JinShil
Copy link
Contributor

JinShil commented Dec 11, 2017

I suspect there is a nice makefile in there somewhere trying to get out.

I never understood why we use something as arcane as make when we have this much more capable and expressive language at our disposal. If you wanna go forward, you gotta put it in D.

@wilzbach
Copy link
Contributor Author

I never understood why we use something as arcane as make when we have this much more capable and expressive language at our disposal. If you wanna go forward, you gotta put it in D.

See e.g. http://forum.dlang.org/post/mailman.3317.1497594616.31550.digitalmars-d@puremagic.com

tl;dr: this pops up every three to six months. The main problem is DM make on Windows which creates a huge chunk of duplication (it's especially bad for Phobos) as it only supports a limited subset of GNUmake.
While many solutions have been proposed (reggae, meson, cmake, ninja, ...), and you can read the NG for the reasons why this is probably not going to happen in the near future (many build systems require another language and things like reggae aren't considered stable enough).
Imho the more realistic option and is to drop support for building DMD on Windows with DM make and expect people to have GNUmake (we could also add a "bootstrap" script, which will do the installation & setup or maybe even ship it as part of the Windows release). This would already by a huge benefit and as Rainers recently pointed out the DMD testsuite already only runs with GNUmake and even expects a Unix-like environment.

@RazvanN7
Copy link
Contributor

RazvanN7 commented Dec 11, 2017

@wilzbach The examples weren't meant to test the parser library, but to offer an example on how the parser visitors can be used. I don't think that moving the sources to the test files is a good idea since those aren't actually tests.

I don't have any other objections regarding this PR

@wilzbach
Copy link
Contributor Author

The examples weren't meant to test the parser library, but to offer an example on how the parser visitors can be used.

Point being was that the examples currently aren't built as part of the test suite, which can easily lead to them being in a broken / outdated state (like e.g. the DUB package which already doesn't work anymore - see #7415).

I don't think that moving the sources to the test files is a good idea since those aren't actually tests.

Well my point was to move them out of the main Makefile, s.t. the "nice Makefile" can slowly start to appear again ;-)

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

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

thx! cc @RazvanN7

@andralex andralex merged commit 7c888c4 into dlang:master Dec 12, 2017
@wilzbach wilzbach deleted the cleanup-dmd-as-a-library branch December 19, 2017 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants