-
-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build option ENABLE_ASSERTS and use it for CI #11523
Conversation
Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#11523" |
[I've grepped for |
fff6b34
to
5871c91
Compare
src/posix.mak
Outdated
@@ -99,7 +100,7 @@ else | |||
HOST_DMD_RUN=$(HOST_DMD) -conf=$(dir $(HOST_DMD))dmd.conf | |||
endif | |||
|
|||
RUN_BUILD = $(GENERATED)/build HOST_DMD="$(HOST_DMD)" CXX="$(HOST_CXX)" OS=$(OS) BUILD=$(BUILD) MODEL=$(MODEL) AUTO_BOOTSTRAP="$(AUTO_BOOTSTRAP)" DOCDIR="$(DOCDIR)" STDDOC="$(STDDOC)" DOC_OUTPUT_DIR="$(DOC_OUTPUT_DIR)" MAKE="$(MAKE)" --called-from-make | |||
RUN_BUILD = $(GENERATED)/build --called-from-make OS="$(OS)" BUILD="$(BUILD)" MODEL="$(MODEL)" HOST_DMD="$(HOST_DMD)" CXX="$(HOST_CXX)" AUTO_BOOTSTRAP="$(AUTO_BOOTSTRAP)" DOCDIR="$(DOCDIR)" STDDOC="$(STDDOC)" DOC_OUTPUT_DIR="$(DOC_OUTPUT_DIR)" MAKE="$(MAKE)" VERBOSE="$(VERBOSE)" ENABLE_RELEASE="$(ENABLE_RELEASE)" ENABLE_DEBUG="$(ENABLE_DEBUG)" ENABLE_ASSERTS="$(ENABLE_ASSERTS)" ENABLE_UNITTEST="$(ENABLE_UNITTEST)" ENABLE_PROFILE="$(ENABLE_PROFILE)" ENABLE_COVERAGE="$(ENABLE_COVERAGE)" DFLAGS="$(DFLAGS)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC build.d
parses ENABLE_
from both CLI arguments and environment arguments and as GNUMake forwards all environment variables, this shouldn't be necessary?
Or was this done for explicitness?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GNU make apparently automatically exports all variables set in the cmdline to the environment (incl. on Windows), but DM make doesn't (at least not on Windows). I wasn't sure whether DM make is supposed to be supported on Posix systems.
And yeah, explicitness is IMO a nice side-effect (looking at the build
cmdline suffices, no need to check earlier make cmdlines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, posix.mak can't even be called with DM make as it uses many features that DM make doesn't support. It will outright fail to even parse the Makefile.
As we are about to finally deprecate these mak files, I'm fine either way. I was just curious, because I thought it wasn't technically necessary.
CC @MoonlightSentinel: you were the one who added the make->build.d call initially. Do you have any objections for or against this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was actually introduced by @marler8997 in e07dc95.
Don't think there is any harm in adding those variables because it doesn't change the behaviour and we're phasing out the makefiles anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I thought dm make did add variables to its environment, which is then available to any invoked command. I wrote that program 35 years ago, I guess I'd have to go look at the source code :-)
The documentation needs some changes though:
|
dflags ~= ["-O", "-release", "-inline"]; | ||
dflags ~= ["-O", "-inline"]; | ||
if (!env.getNumberedBool("ENABLE_ASSERTS")) | ||
dflags ~= ["-release"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that we shouldn't forget is that -release
might generate different code with DMD, so it might be worthwhile to do this only for certain CIs.
Additionally, to tackle this problem on newer CIs there's -check
switch, so we conditionally on the host compiler version we could do -release -check=assert=on
.
The Circle build is a quick one and skips some tests AFAIK. And I don't think any assertions are enabled on Windows, as there was a pretty wild failing assertion not too long ago wrt.
Well I definitely want bounds checks (in |
Assertions were enabled and caused the
Me too, I was just concerned that the name could be confusing (although the probability should be quite low). Anyway, those points were just bugging me personally, so don't let them stop this improvement. |
Windows_LDC_Debug x64-debug-ldc builds dmd with |
I've pushed a little test to see where the assertions are still disabled - and those are the 2 non-debug MSBuild-based Azure jobs [the debug job hangs after hitting the assertion and doesn't cleanly terminate]. Not sure whether the auto-tester will process the remaining outstanding jobs. So assertions have been enabled for the trimmed-down testsuite for CircleCI on Linux x64, and the (full?) testsuite for 1 Azure job on a Win64 host with MSVC runtime, and now basically all others (incl. 32-bit hosts, MacOS, FreeBSD, OMF/DMC) feature these checks too, with one notable exception: Win32 with MSVC runtime, and I think that corresponds to the prebuilt 32-bit Windows binaries. |
Not sure if that's what you meant by "prebuilt", but the passing builds are using the VS projects to build dmd. ENABLE_ASSERTS has no effect on these. |
I meant that that platform is the only one which isn't CI-tested with enabled assertions, and if the official Win32 DMD binaries are built with LDC, it would IMO be more important to test than Win32 OMF (tested twice with enabled assertions - Azure + auto-tester). |
Replacing
with
in the VS project removes "-release" from the command line. |
I've added a |
Msg revised. |
f337c88
to
5008c19
Compare
To finally have DMD's own assertions properly CI-tested. Assertions have so far only been enabled for CircleCI (reduced testsuite on Linux x64) and one Azure job (Win64 debug).
Required for DigitalMars make, which doesn't export the variables set in the make cmdline to the environment.
A copy of the Release configuration, except for omitting `-release` (`<DebugCode>Default</DebugCode>`) [and not predefining NDEBUG for C++].
Rebased, in case the previous unrelated CI hiccups have been the reason this isn't merged yet. |
ci.sh
Outdated
@@ -45,7 +45,7 @@ clone() { | |||
# build dmd, druntime, phobos | |||
build() { | |||
source ~/dlang/*/activate # activate host compiler | |||
make -j$N -C src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD ENABLE_RELEASE=1 ENABLE_WARNINGS=1 all | |||
make -j$N -C src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD ENABLE_RELEASE=1 ENABLE_ASSERTS=1 ENABLE_WARNINGS=1 all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be manually enabled per CI by passing ENABLE_ASSERTS=1
as an environment variable.
(To tackle https://github.com/dlang/dmd/pull/11523/files#r471124647)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get your point, and I thought we've established that omitting -release
is the way to go, better than to rely on host-compiler-version-specific -check
switches. -release
is IMO there for a reason and is the standard way of en/disabling default safety checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To quote @wilzbach:
One thing that we shouldn't forget is that -release might generate different code with DMD, so it might be worthwhile to do this only for certain CIs.
There are still releases compiled by dmd
+ -release
IIRC, so we should test it at least on one CI. Or am I missing a CI that isn't affected by your changes?
EDIT: There's BuildKite but it doesn't run DMD's test suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sry I misunderstood; TBH, I couldn't imagine checked assertions etc. to have side effects wrt. generated code, but well, it most likely cannot be ruled out. I'm not too familiar with DMD's CI and what each one does exactly, so someone else pls take care of selecting the job(s) to be built without assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither but better safe than sorry,
I would suggest removing this line all changes in this file s.t. SemaphoreCI remains in it's current state and all other CI's run without -release
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
To restore some CI coverage with disabled assertions as suggested by Seb & Florian.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment on the VS-related changes but the rest LGTM
To finally have DMD's own assertions properly CI-tested.