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-libc support #216

Closed
nightah opened this issue Mar 14, 2020 · 7 comments
Closed

musl-libc support #216

nightah opened this issue Mar 14, 2020 · 7 comments

Comments

@nightah
Copy link

nightah commented Mar 14, 2020

Thanks for this fantastic project! I had a little play around on my primary driver which is Arch Linux and glibc, everything worked great.

I have just attempted to build osxcross on an Alpine Linux based container and ran in to issues.

The build fails with the following error:

sed -e s/@LIBXAR_SNAME@/libxar.so.1/ -e s/@LIBXAR_LNAME@/libxar.so/ -e s/@LIBXAR_ANAME@/libxar.a/ < lib/libxar.la.in > lib/libxar.la
src/xar.c:40:10: fatal error: 'fts.h' file not found
#include <fts.h>
         ^~~~~~~
clang -shared -Wl,-soname,libxar.so.1 -o lib/librxar.so.1 lib/archive.o lib/arcmod.o lib/b64.o lib/bzxar.o lib/darwinattr.o lib/data.o lib/ea.o lib/err.o lib/ext2.o lib/fbsdattr.o lib/filetree.o lib/io.o lib/lzmaxar.o lib/linuxattr.o lib/hash.o lib/signature.o lib/stat.o lib/subdoc.o lib/util.o lib/zxar.o lib/script.o lib/macho.o -Llib  -llzma -lz -lcrypto  -lxml2 -L/lib -lz -llzma -lm
clang -shared -Wl,-soname,libxar.so.1 -o lib/libxar.so.1 lib/archive.o lib/arcmod.o lib/b64.o lib/bzxar.o lib/darwinattr.o lib/data.o lib/ea.o lib/err.o lib/ext2.o lib/fbsdattr.o lib/filetree.o lib/io.o lib/lzmaxar.o lib/linuxattr.o lib/hash.o lib/signature.o lib/stat.o lib/subdoc.o lib/util.o lib/zxar.o lib/script.o lib/macho.o -Llib  -llzma -lz -lcrypto  -lxml2 -L/lib -lz -llzma -lm
1 error generated.
make: *** [src/Makefile.inc:66: src/xar.o] Error 1
make: *** Waiting for unfinished jobs....
rm -f lib/libxar.so
rm -f lib/librxar.so
ln -s libxar.so.1 lib/libxar.so
ln -s librxar.so.1 lib/librxar.so

exiting with abnormal exit code (2)
run 'OCDEBUG=1 ./build.sh' to enable debug messages

The above error is related to this.
I have also attempted to install fts-dev and that results in the following error:

/usr/bin/ranlib lib/libxar.a
clang -w  -o src/xar src/xar.o -Wl,-rpath,/build/build/xar/xar/lib -Llib  lib/libxar.a -llzma -lz -lcrypto  -lxml2 -L/lib -lz -llzma -lm
clang -w  -o src/ixar src/xar.o -Wl,-rpath,/build/target/lib -Llib  lib/libxar.so.1 -llzma -lz -lcrypto  -lxml2 -L/lib -lz -llzma -lm
/usr/bin/ld: src/xar.o: in function `archive':
xar.c:(.text+0x3f2b): undefined reference to `fts_open'
/usr/bin/ld: xar.c:(.text+0x3f70): undefined reference to `fts_read'
/usr/bin/ld: xar.c:(.text+0x417d): undefined reference to `fts_close'
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
/usr/bin/ld: src/xar.o: in function `archive':
xar.c:(.text+0x3f2b): undefined reference to `fts_open'
/usr/bin/ld: xar.c:(.text+0x3f70): undefined reference to `fts_read'
/usr/bin/ld: xar.c:(.text+0x417d): undefined reference to `fts_close'
make: *** [src/Makefile.inc:58: src/ixar] Error 1
make: *** Waiting for unfinished jobs....
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [src/Makefile.inc:42: src/xar] Error 1

exiting with abnormal exit code (2)
run 'OCDEBUG=1 ./build.sh' to enable debug messages

You can follow these steps with Docker to replicate the environment and error:

  1. cd to /path/of/osxbuild
  2. Ensure that the packaged SDK is in the tarballs/ directory
  3. docker run --rm -it --entrypoint /bin/ash -v $PWD:/build alpine
  4. apk add --no-cache bash clang cmake gcc git libxml2-dev make musl-dev openssl-dev patch python3
  5. cd /build && ./build.sh
    This will allow you to replicate the first error
  6. apk add --no-cache fts-dev
  7. ./build.sh
    This will allow you to replicate the second error

I'm not entirely certain what the stance is on musl-libc, any help would be appreciated and if there's anything I can do to help debug/support please let me know.

tpoechtrager added a commit to tpoechtrager/xar that referenced this issue Mar 14, 2020
@tpoechtrager
Copy link
Owner

tpoechtrager commented Mar 14, 2020

Fixed. Thanks for the detailed report.

You will also need g++ and clang-dev to make OSXCross build.

@nightah
Copy link
Author

nightah commented Mar 14, 2020

Great, thanks for the prompt fix and response. I’ll give it a whirl in a couple hours.

@nightah
Copy link
Author

nightah commented Mar 14, 2020

@tpoechtrager on the back of this I was able to get OSXCross built, however, it looks like I'm having trouble building the cross-compiler with gcc.

I had to add a couple extra packages per the warnings:

apk add --no-cache gmp-dev mpfr-dev mpc1-dev

But it seems to result in the following error:

/build/target/bin/x86_64-apple-darwin19-ranlib: archive member: libgcov.a(_gcov_merge_add.o) size too large (archive member extends past the end of the file)
x86_64-apple-darwin19-ar: internal ranlib command failed
/build/build/gcc-9.2.0/build/./gcc/xgcc -B/build/build/gcc-9.2.0/build/./gcc/ -B/build/target/bin/../x86_64-apple-darwin19/bin/ -B/build/target/bin/../x86_64-apple-darwin19/lib/ -isystem /build/target/bin/../x86_64-apple-darwin19/include -isystem /build/target/bin/../x86_64-apple-darwin19/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe -fno-common -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o sse_savms64.o -MT sse_savms64.o -MD -MP -MF sse_savms64.dep -c -xassembler-with-cpp -include sse_savms64.vis ../../../libgcc/config/i386/sse_savms64.S
/build/target/bin/x86_64-apple-darwin19-ranlib: archive member: libgcc_eh.a(nality_v0) size too large (archive member extends past the end of the file)
make[2]: *** [Makefile:936: libgcov.a] Error 1
x86_64-apple-darwin19-ar: internal ranlib command failed
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:936: libgcc_eh.a] Error 1
libtool: link: (cd ".libs" && rm -f "libcp1plugin.so.0" && ln -s "libcp1plugin.so.0.0.0" "libcp1plugin.so.0")
libtool: link: (cd ".libs" && rm -f "libcp1plugin.so" && ln -s "libcp1plugin.so.0.0.0" "libcp1plugin.so")
libtool: link: ( cd ".libs" && rm -f "libcp1plugin.la" && ln -s "../libcp1plugin.la" "libcp1plugin.la" )
make[3]: Leaving directory '/build/build/gcc-9.2.0/build/libcc1'
make[2]: Leaving directory '/build/build/gcc-9.2.0/build/libcc1'
make[2]: Leaving directory '/build/build/gcc-9.2.0/build/x86_64-apple-darwin19/libgcc'
make[1]: *** [Makefile:12010: all-target-libgcc] Error 2
make[1]: Leaving directory '/build/build/gcc-9.2.0/build'
make: *** [Makefile:954: all] Error 2

exiting with abnormal exit code (2)
run 'OCDEBUG=1 ./build_gcc.sh' to enable debug messages

Happy to lodge this as another issue if required with reproduction steps, please let me know.

@tpoechtrager
Copy link
Owner

Yeah I already noticed. There is something wrong with the archiver (AR). I have to debug it.

@tpoechtrager tpoechtrager reopened this Mar 14, 2020
@nightah
Copy link
Author

nightah commented Mar 14, 2020

No problems, I'll hang tight.

Let me know if there's anything I can help with, thanks again!

tpoechtrager added a commit to tpoechtrager/cctools-port that referenced this issue Mar 14, 2020
@tpoechtrager
Copy link
Owner

Found the cause and fixed it.

@nightah
Copy link
Author

nightah commented Mar 15, 2020

Perfect, so it looks like the only thing missing since your last fix is that you also need perl to compile GCC.

@nightah nightah closed this as completed Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants