When building a Python extension module on macOS (both x86-64 and arm64) with clang or clang++, you will see this warning for each extension (example log from a conda-forge SciPy build):
ld: warning: -pie being ignored. It is only used when linking a main executable
When you build a package like SciPy, that's O(100) warnings.
The problem isn't actually limited to macOS I think, I just don't see it on Linux because the compilers package pulls in GCC rather than Clang.
I have read https://conda-forge.org/docs/user/faq.html#faq-compiler-required-options, but I don't think adding -fPIE is one of the options that qualifies here - because it is not a flag that is valid for building Python extensions nor other types of binaries that aren't a main executable. Therefore I don't think it should be added by default.
I can imagine that the choice was made to only do this in Clang because macOS seemingly preferring position independent executables (https://en.wikipedia.org/wiki/Position-independent_code#Position-independent_executables) and warning on non-PIE binaries being uploaded to the App Store. That said, this should be dealt with in the build options for packages that are main executables though, and not for every compiler invocation.
When building a Python extension module on macOS (both x86-64 and arm64) with
clang
orclang++
, you will see this warning for each extension (example log from a conda-forge SciPy build):When you build a package like SciPy, that's O(100) warnings.
The problem isn't actually limited to macOS I think, I just don't see it on Linux because the
compilers
package pulls in GCC rather than Clang.I have read https://conda-forge.org/docs/user/faq.html#faq-compiler-required-options, but I don't think adding
-fPIE
is one of the options that qualifies here - because it is not a flag that is valid for building Python extensions nor other types of binaries that aren't a main executable. Therefore I don't think it should be added by default.I can imagine that the choice was made to only do this in Clang because macOS seemingly preferring position independent executables (https://en.wikipedia.org/wiki/Position-independent_code#Position-independent_executables) and warning on non-PIE binaries being uploaded to the App Store. That said, this should be dealt with in the build options for packages that are main executables though, and not for every compiler invocation.