lancaster-university / codal-core

MIT License
11 stars 28 forks source link

[Clang compatibility] Preprocessor Directives to ignore builtin clang function #161

Closed Johnn333 closed 1 year ago

Johnn333 commented 1 year ago

__sync_fetch_and_add_2() is a clang builtin, do not declare this function separately when building with clang.

microbit-carlos commented 1 year ago

@Johnn333 this is also a built-in in GCC: https://github.com/gcc-mirror/gcc/blob/63663e4e69527b308687c63bacb0cc038b386593/gcc/sync-builtins.def#L35

Did the compilation fail with LLVM? I assume it would be a weak symbol as well in LLVM to allow user to overwrite the default?

Johnn333 commented 1 year ago

@Johnn333 this is also a built-in in GCC: https://github.com/gcc-mirror/gcc/blob/63663e4e69527b308687c63bacb0cc038b386593/gcc/sync-builtins.def#L35

Did the compilation fail with LLVM? I assume it would be a weak symbol as well in LLVM to allow user to overwrite the default?

Yes, it fails when building with LLVM. A better patch may be the use the __has_builtin macro. But the current PR does fix compilation errors when using LLVM.