Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 08, 2016 Asserts in C++ code not working for debug builds? | ||||
---|---|---|---|---|
| ||||
Hi all, I just had a PR fail a CI test because of an assert being triggered. But... I am on the same platform (Mac), doing the same build (Debug), or so I thought. Indeed, if I change an assert to something bad (i.e. remove a "!"), nothing happens. What's wrong with my setup? I am compiling LDC in debug mode, but I am using a release-mode LLVM (speed...). This means llvm-config will return "-DNDEBUG" as one of the --cxxflags, and all my asserts are disabled. (It also sets "-O3" for the LDC build) Advice? -Johan |
July 08, 2016 Re: Asserts in C++ code not working for debug builds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | On Friday, 8 July 2016 at 20:10:37 UTC, Johan Engelen wrote:
> Hi all,
> I just had a PR fail a CI test because of an assert being triggered.
Btw, asserts are apparently disabled for all our Linux CI builds.
Mac and Windows CI systems do build with asserts; Windows also for release builds (!)
|
July 08, 2016 Re: Asserts in C++ code not working for debug builds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | On 8 Jul 2016, at 21:10, Johan Engelen via digitalmars-d-ldc wrote:
> What's wrong with my setup? I am compiling LDC in debug mode, but I am using a release-mode LLVM (speed...). This means llvm-config will return "-DNDEBUG" as one of the --cxxflags, and all my asserts are disabled. (It also sets "-O3" for the LDC build)
>
> Advice?
IIRC, the LLVM ABI changes depending on whether (N)DEBUG is enabled when including the headers, which has actually led to hard to debug issues in the past.
A Google or Git history search will probably turn up the exact places it does. Assuming you want to disable the LLVM assertions for speed and not just have an optimised build (which would of course easily be possible), you would need to look into whether there is a way (a preprocessor flag separate from NDEBUG, etc.) to keep the ABI the same as for debug builds while eliding assertions.
— David
|
July 09, 2016 Re: Asserts in C++ code not working for debug builds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Friday, 8 July 2016 at 20:55:50 UTC, David Nadlinger wrote: > On 8 Jul 2016, at 21:10, Johan Engelen via digitalmars-d-ldc wrote: >> What's wrong with my setup? I am compiling LDC in debug mode, but I am using a release-mode LLVM (speed...). This means llvm-config will return "-DNDEBUG" as one of the --cxxflags, and all my asserts are disabled. (It also sets "-O3" for the LDC build) >> >> Advice? > > IIRC, the LLVM ABI changes depending on whether (N)DEBUG is enabled when including the headers, which has actually led to hard to debug issues in the past. Every now and then, the need to remove NDEBUG dependency in headers pops up on the LLVM maillist. I don't think it's solved yet. > A Google or Git history search will probably turn up the exact places it does. Assuming you want to disable the LLVM assertions for speed and not just have an optimised build (which would of course easily be possible) Yeah, I think this is the solution. I'm going to try with a Release build of LLVM with assertions explicitly enabled. We have to keep in mind that none of the Linux builds are with assertions enabled! |
July 09, 2016 Re: Asserts in C++ code not working for debug builds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | On Saturday, 9 July 2016 at 08:28:22 UTC, Johan Engelen wrote:
> On Friday, 8 July 2016 at 20:55:50 UTC, David Nadlinger wrote:
>> IIRC, the LLVM ABI changes depending on whether (N)DEBUG is enabled when including the headers, which has actually led to hard to debug issues in the past.
>
> Every now and then, the need to remove NDEBUG dependency in headers pops up on the LLVM maillist. I don't think it's solved yet.
Nope, e.g., I can't build a debug LDC with a RelWithDebInfo LLVM and LLVM assertions explicitly enabled (on Windows, with MSVC). So I simply use a RelWithDebInfo LDC, assertions enabled.
|
July 09, 2016 Re: Asserts in C++ code not working for debug builds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | On Saturday, 9 July 2016 at 08:28:22 UTC, Johan Engelen wrote:
>
> I'm going to try with a Release build of LLVM with assertions explicitly enabled.
This seems to work for me now
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON
|
July 11, 2016 Re: Asserts in C++ code not working for debug builds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Friday, 8 July 2016 at 20:55:50 UTC, David Nadlinger wrote:
> IIRC, the LLVM ABI changes depending on whether (N)DEBUG is enabled when including the headers, which has actually led to hard to debug issues in the past.
As long as I am reading the LLVM mailing list this is an issue which is discussed every half year. Don't know if they resolved it.
Regards,
Kai
|
Copyright © 1999-2021 by the D Language Foundation