Not all options are passed on to bcc64x.exe

TwineCompile - Cut C++Builder compile times by up to 50x!
Post Reply
Richard_008
Posts: 45
Joined: Mon Sep 21, 2020 11:53 am

Not all options are passed on to bcc64x.exe

Post by Richard_008 »

The (relatively new) project options "BCC_InstructionSet_v15", "BCC_AddressSanitizer" and "BCC_UndefinedBehaviorSanitizer" are not passed on to bcc64x.exe. I accidentally found this out when my PCH file was compiled by TwineCompile and I tried to compile a cpp file directly with bcc64x.exe. This may explain why I was never able to notice a difference with these options. I was assuming every option (whether new or old) would have been passed on to bcc64x.exe. And I am wondering if it is possible some other options also aren't passed on (correctly).

The errors I got were:

Code: Select all

\CodeGear.Cpp.Targets(3044,5): error E790: current translation unit is compiled with the target feature '-fsanitize=address' but the AST file was not
\CodeGear.Cpp.Targets(3044,5): error E790: current translation unit is compiled with the target feature '+sse4.2' but the AST file was not

When not using TwineCompile, bcc64x.exe gets these options:

With "BCC_InstructionSet_v15":

Code: Select all

-target-feature +sse4.2
With "BCC_UndefinedBehaviorSanitizer":

Code: Select all

-fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr 
-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr
With "BCC_AddressSanitizer":

Code: Select all

-fsanitize=address 
-fsanitize-address-use-after-scope 
-fsanitize-address-globals-dead-stripping 
-fno-assume-sane-operator-new
Combined:

Code: Select all

-target-feature +sse4.2
-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr 
-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr 
-fsanitize-address-use-after-scope 
-fsanitize-address-globals-dead-stripping 
-fno-assume-sane-operator-new
oliwe
Posts: 25
Joined: Mon Feb 08, 2021 7:13 am

Re: Not all options are passed on to bcc64x.exe

Post by oliwe »

I was building one Project with TwineCompile in order to test the Sanitizer and they did not work.
Maybe caused by this. I have to investigate this further.
jomitech
Site Admin
Posts: 2193
Joined: Wed Oct 08, 2008 12:23 am

Re: Not all options are passed on to bcc64x.exe

Post by jomitech »

Apologies for this issue. I have attached a revised targets file that should resolve this issue. Extract into the TwineCompile Program Files directory.
Jon
Richard_008
Posts: 45
Joined: Mon Sep 21, 2020 11:53 am

Re: Not all options are passed on to bcc64x.exe

Post by Richard_008 »

Thanks for the quick fix! Seems to work for me.
Richard_008
Posts: 45
Joined: Mon Sep 21, 2020 11:53 am

Re: Not all options are passed on to bcc64x.exe

Post by Richard_008 »

I actually did run into a problem. When I build the project from a clean with TwineCompile, I get these linking errors:

Code: Select all

[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_type_mismatch_v1
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_dynamic_type_cache_miss
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_pointer_overflow
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_load_invalid_value
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_out_of_bounds
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_builtin_unreachable
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_divrem_overflow
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_alignment_assumption
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_mul_overflow
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_sub_overflow
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_invalid_builtin
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_add_overflow
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_vptr_type_cache
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_float_cast_overflow
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_shift_out_of_bounds
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_negate_overflow
[TCBuild Error]  ld.lld: error: undefined symbol: __ubsan_handle_nonnull_arg
When I try to link without TwineCompile (with the files compiled by TwineCompile), I get the same errors. The other way around (so files compiled without TwineCompile, linking with TwineCompile) I have no issues. So the problem is with the compilation, not the linking.

It probably has to do with these options that bcc64x gets:

Code: Select all

--dependent-lib=libclang_rt.ubsan_standalone-x86_64.a 
--dependent-lib=libclang_rt.ubsan_standalone_cxx-x86_64.a
I couldn't verify if they were passed on by TwineCompile, but my guess would be no.
jomitech
Site Admin
Posts: 2193
Joined: Wed Oct 08, 2008 12:23 am

Re: Not all options are passed on to bcc64x.exe

Post by jomitech »

Can you send a sample project that reproduces this issue to support@jomitech.com? I'm having trouble reproducing it.
Jon
Richard_008
Posts: 45
Joined: Mon Sep 21, 2020 11:53 am

Re: Not all options are passed on to bcc64x.exe

Post by Richard_008 »

I think you are trying to reproduce it with both "BCC_UndefinedBehaviorSanitizer" and "BCC_AddressSanitizer" turned on. In that case, I also have no problems. The errors occur with only "BCC_UndefinedBehaviorSanitizer" on. Only having "BCC_AddressSanitizer" is no problem. I have just emailed you a sample project (and also attached it to this message).
Attachments
TestProject.7z
(5.77 KiB) Downloaded 232 times
jomitech
Site Admin
Posts: 2193
Joined: Wed Oct 08, 2008 12:23 am

Re: Not all options are passed on to bcc64x.exe

Post by jomitech »

Thanks for the test case, I was able to reproduce it. And yes, you're correct, I was testing with both options enabled. Did not expect a missing library to be resolve by having the address sanitizer turned on.

The attached targets file should resolve the issue.
Attachments
TCTargets121.zip
(8.27 KiB) Downloaded 199 times
Jon
Richard_008
Posts: 45
Joined: Mon Sep 21, 2020 11:53 am

Re: Not all options are passed on to bcc64x.exe

Post by Richard_008 »

I had the same problem trying to get the sample project to reproduce the errors :).
Now I can completely compile with TwineCompile without problems. Thanks!
jomitech
Site Admin
Posts: 2193
Joined: Wed Oct 08, 2008 12:23 am

Re: Not all options are passed on to bcc64x.exe

Post by jomitech »

Glad to hear it's resolved for you.
Jon
Post Reply