Page 1 of 1

Not all options are passed on to bcc64x.exe

Posted: Tue May 06, 2025 6:01 am
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

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

Posted: Wed May 07, 2025 5:00 am
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.

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

Posted: Wed May 07, 2025 4:12 pm
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.

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

Posted: Thu May 08, 2025 10:15 am
by Richard_008
Thanks for the quick fix! Seems to work for me.

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

Posted: Mon May 12, 2025 3:56 am
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.

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

Posted: Mon May 12, 2025 4:23 pm
by jomitech
Can you send a sample project that reproduces this issue to support@jomitech.com? I'm having trouble reproducing it.

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

Posted: Wed May 14, 2025 10:22 am
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).

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

Posted: Wed May 14, 2025 4:26 pm
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.

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

Posted: Thu May 15, 2025 9:54 am
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!

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

Posted: Thu May 15, 2025 8:05 pm
by jomitech
Glad to hear it's resolved for you.