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

Musl rootfs lacks libssp_nonshared for -fstack-protector #739

Open
maleadt opened this issue Apr 3, 2020 · 2 comments
Open

Musl rootfs lacks libssp_nonshared for -fstack-protector #739

maleadt opened this issue Apr 3, 2020 · 2 comments
Labels
BinaryBuilder ⚙️ Issues and pull requested related to internals of BinaryBuilder bug 🐛 Something isn't working

Comments

@maleadt
Copy link
Contributor

maleadt commented Apr 3, 2020

I'm having some trouble building libigc for x86_64-linux-musl, whereas glibc works perfectly.
The issue I'm running into, as encountered with #743:

[ 79%] Linking CXX executable ../Release/elf_packager
cd /workspace/srcdir/intel-graphics-compiler-igc-1.0.3586/build/IGC/ElfPackager && /usr/bin/cmake -E cmake_link_script CMakeFiles/elf_packager.dir/link.txt --verbose=true
/opt/bin/x86_64-linux-musl-g++ --sysroot=/opt/x86_64-linux-musl/x86_64-linux-musl/sys-root/  -fno-exceptions -fdata-sections -ffunction-sections -O2 -pipe -fmessage-length=0 -march=corei7 -mstackrealign -fms-extensions -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wwrite-strings -Wno-long-long -Wswitch -Wno-sign-compare -Wno-unused-result -Wno-enum-compare -Wno-type-limits -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-extra -Wno-write-strings -finline -fno-strict-aliasing -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -Wno-unknown-pragmas -fPIC -D_FORTIFY_SOURCE=2 -fstack-protector -finline-functions -funswitch-loops -Wno-maybe-uninitialized -lrt -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -g  -Wl,--gc-sections -rdynamic CMakeFiles/elf_packager.dir/main.cpp.o CMakeFiles/elf_packager.dir/__/AdaptorOCL/CLElfLib/ElfWriter.cpp.o CMakeFiles/elf_packager.dir/__/AdaptorOCL/CLElfLib/ElfReader.cpp.o  -o ../Release/elf_packager ../llvm/build/src/lib/libLLVMipo.a ../llvm/build/src/lib/libLLVMIRReader.a ../llvm/build/src/lib/libLLVMBitWriter.a ../llvm/build/src/lib/libLLVMBinaryFormat.a ../llvm/build/src/lib/libLLVMAsmParser.a ../llvm/build/src/lib/libLLVMBitReader.a ../llvm/build/src/lib/libLLVMLinker.a ../llvm/build/src/lib/libLLVMCodeGen.a ../llvm/build/src/lib/libLLVMScalarOpts.a ../llvm/build/src/lib/libLLVMTransformUtils.a ../llvm/build/src/lib/libLLVMAnalysis.a ../llvm/build/src/lib/libLLVMTarget.a ../llvm/build/src/lib/libLLVMObjCARCOpts.a ../llvm/build/src/lib/libLLVMVectorize.a ../llvm/build/src/lib/libLLVMInstrumentation.a ../llvm/build/src/lib/libLLVMObject.a ../llvm/build/src/lib/libLLVMMCParser.a ../llvm/build/src/lib/libLLVMProfileData.a ../llvm/build/src/lib/libLLVMMC.a ../llvm/build/src/lib/libLLVMCore.a ../llvm/build/src/lib/libLLVMSupport.a ../llvm/build/src/lib/libLLVMDemangle.a ../llvm/build/src/lib/libLLVMInstCombine.a ../llvm/build/src/lib/libLLVMBitstreamReader.a ../llvm/build/src/lib/libLLVMBitWriter.a ../llvm/build/src/lib/libLLVMAggressiveInstCombine.a ../llvm/build/src/lib/libLLVMTransformUtils.a ../llvm/build/src/lib/libLLVMAnalysis.a ../llvm/build/src/lib/libLLVMObject.a ../llvm/build/src/lib/libLLVMBitReader.a ../llvm/build/src/lib/libLLVMBitstreamReader.a ../llvm/build/src/lib/libLLVMMCParser.a ../llvm/build/src/lib/libLLVMMC.a ../llvm/build/src/lib/libLLVMDebugInfoCodeView.a ../llvm/build/src/lib/libLLVMDebugInfoMSF.a ../llvm/build/src/lib/libLLVMProfileData.a ../llvm/build/src/lib/libLLVMCore.a ../llvm/build/src/lib/libLLVMBinaryFormat.a ../llvm/build/src/lib/libLLVMRemarks.a ../llvm/build/src/lib/libLLVMSupport.a ../llvm/build/src/lib/libLLVMDemangle.a -lrt -ldl -lm 
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/5.2.0/../../../../x86_64-linux-musl/bin/ld: cannot find -lssp_nonshared
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/5.2.0/../../../../x86_64-linux-musl/bin/ld: cannot find -lssp
collect2: error: ld returned 1 exit status

This can be reduced to:

# /opt/bin/x86_64-linux-musl-g++ -fstack-protector -lrt 
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/5.2.0/../../../../x86_64-linux-musl/bin/ld: cannot find -lssp_nonshared
/opt/x86_64-linux-musl/bin/../lib/gcc/x86_64-linux-musl/5.2.0/../../../../x86_64-linux-musl/bin/ld: cannot find -lssp
collect2: error: ld returned 1 exit status

Some googling around "musl ssp_nonshared" reveals I'd need to apk add musl-dev, but this is a cross build so installing native libs in the sandbox does not help me. Instead, it looks like Musl_jll should provide than just ld-musl.so it does not, e.g., Alpine's musl-dev provides several other includes and libraries: https://pkgs.alpinelinux.org/contents?branch=v3.3&name=musl-dev&arch=x86&repo=main

Can be worked around by patching away -fstack-protector

@maleadt maleadt changed the title Musl rootfs lacks libssp_nonshared Musl rootfs lacks libssp_nonshared for -fstack-protector Apr 3, 2020
@Crghilardi Crghilardi mentioned this issue Aug 17, 2021
@giordano
Copy link
Member

@Crghilardi pointed out we explicitly disable libssp on Musl:

# On musl targets, disable a bunch of things we don't want
if [[ "${COMPILER_TARGET}" == *-musl* ]]; then
GCC_CONF_ARGS="${GCC_CONF_ARGS} --disable-libssp --disable-libmpx --disable-libmudflap"

I guess the why is a question for @staticfloat

@giordano giordano added BinaryBuilder ⚙️ Issues and pull requested related to internals of BinaryBuilder bug 🐛 Something isn't working labels Aug 17, 2021
@staticfloat
Copy link
Member

I was never able to build GCC targeting musl with libssp. Perhaps support has improved, I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BinaryBuilder ⚙️ Issues and pull requested related to internals of BinaryBuilder bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants