Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent clang --target behavior across musl archs #89146

Open
am11 opened this issue Apr 17, 2024 · 1 comment
Open

Inconsistent clang --target behavior across musl archs #89146

am11 opened this issue Apr 17, 2024 · 1 comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@am11
Copy link

am11 commented Apr 17, 2024

It appears clang is able to locate the gcc toolchain from triplet without distro name for aarch64, but not armv7:
Setup:

# aarch64 gcc toolchain
$ ls /crossrootfs/arm64/usr/lib/gcc
aarch64-alpine-linux-musl

# armv7 gcc toolchain
$ ls /crossrootfs/arm/usr/lib/gcc
armv7-alpine-linux-musleabihf

Test:

✅ aarch64-alpine-linux-musl
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm64" --target=aarch64-alpine-linux-musl

✅ aarch64-linux-musl
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm64" --target=aarch64-linux-musl

✅ armv7-alpine-linux-musleabihf
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm" --target=armv7-alpine-linux-musleabihf

❌ armv7-linux-musleabihf
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm" --target=armv7-linux-musleabihf
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
clang-18: error: linker command failed with exit code 1 (use -v to see invocation)

Other musllibc-based distros use neutral names for gcc toolchain: ${arch}-linux-musl. Due to this disparity in identifying gcc toolchain, we would need to special case musleabihf for Alpine Linux.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Apr 17, 2024
@EugeneZelenko EugeneZelenko added clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' and removed clang Clang issues not falling into any other category labels Apr 17, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 17, 2024

@llvm/issue-subscribers-clang-driver

Author: Adeel Mujahid (am11)

It appears clang is able to locate the gcc toolchain from triplet without distro name for aarch64, but not armv7: Setup: ```sh # aarch64 gcc toolchain $ ls /crossrootfs/arm64/usr/lib/gcc aarch64-alpine-linux-musl

armv7 gcc toolchain

$ ls /crossrootfs/arm/usr/lib/gcc
armv7-alpine-linux-musleabihf


Test:
```sh
✅ aarch64-alpine-linux-musl
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm64" --target=aarch64-alpine-linux-musl

✅ aarch64-linux-musl
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm64" --target=aarch64-linux-musl

✅ armv7-alpine-linux-musleabihf
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm" --target=armv7-alpine-linux-musleabihf

❌ armv7-linux-musleabihf
$ echo "int main(void) { }" | clang-18 -xc - --sysroot="/crossrootfs/arm" --target=armv7-linux-musleabihf
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
clang-18: error: linker command failed with exit code 1 (use -v to see invocation)

Other musllibc-based distros use neutral names for gcc toolchain: ${arch}-linux-musl. Due to this disparity in identifying gcc toolchain, we would need to special case musleabihf for Alpine Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

No branches or pull requests

3 participants