conda-forge / clang-compiler-activation-feedstock

A conda-smithy repository for clang-compiler-activation.
BSD 3-Clause "New" or "Revised" License
2 stars 17 forks source link

Using -fPIE/-pie on macOS results in many spurious warnings #88

Closed rgommers closed 2 years ago

rgommers commented 2 years ago

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.

isuruf commented 2 years ago

Ah I didn't see this, so I transferred the ctng compilers issue. Marking as duplicate of https://github.com/conda-forge/clang-compiler-activation-feedstock/issues/90