Home > Back-end >  Cross-compiling libunwind results in a missing shared library
Cross-compiling libunwind results in a missing shared library

Time:11-28

I'm trying to cross-compile libunwind to aarch64 architecture using the following command:

./configure --prefix=/home/test/libunwind/arm_build --libdir=/home/test/libunwind/arm_build/lib --target=aarch64 --host=x86_64 CC=/home/gcc-10.3/bin/aarch64-none-linux-gnu-gcc CXX=arm-none-linux-gnu-g LDFLAGS="-L$PWD/src/.libs" --enable-shared=yes

However, this results in the following files being compiled:

~/libunwind » tree arm_build                                                                                                                    
arm_build
├── include
│   ├── libunwind-aarch64.h
│   ├── libunwind-common.h
│   ├── libunwind-coredump.h
│   ├── libunwind-dynamic.h
│   ├── libunwind-ptrace.h
│   └── libunwind-x86.h
└── lib
    ├── libunwind-aarch64.a
    ├── libunwind-aarch64.la
    ├── libunwind-x86.a
    ├── libunwind-x86.la
    └── pkgconfig
        ├── libunwind-coredump.pc
        ├── libunwind-generic.pc
        └── libunwind-ptrace.pc

3 directories, 13 files

I have also tried to build it on the native x86 architecture (./configure --prefix=/home/test/libunwind/x86_build to see whether that produces the shared library, and it sure does, as shown below:

~/libunwind » tree x86_build                                                                                                                    
x86_build                                                                                                                                                                         
├── include                                                                                                                                                                       
│   ├── libunwind-common.h                                                                                                                                                        
│   ├── libunwind-coredump.h                                                                                                                                                      
│   ├── libunwind-dynamic.h                                                                                                                                                       
│   ├── libunwind.h                                                                                                                                                               
│   ├── libunwind-ptrace.h                                                                                                                                                        
│   ├── libunwind-x86_64.h                                                                                                                                                        
│   └── unwind.h                                                                                                                                                                  
└── lib      
    ├── libunwind.a                                                                                                                                                               
    ├── libunwind-coredump.a
    ├── libunwind-coredump.la
    ├── libunwind-coredump.so -> libunwind-coredump.so.0.0.0
    ├── libunwind-coredump.so.0 -> libunwind-coredump.so.0.0.0
    ├── libunwind-coredump.so.0.0.0
    ├── libunwind-generic.a -> libunwind-x86_64.a
    ├── libunwind-generic.so -> libunwind-x86_64.so
    ├── libunwind.la
    ├── libunwind-ptrace.a
    ├── libunwind-ptrace.la
    ├── libunwind-ptrace.so -> libunwind-ptrace.so.0.0.0
    ├── libunwind-ptrace.so.0 -> libunwind-ptrace.so.0.0.0
    ├── libunwind-ptrace.so.0.0.0
    ├── libunwind-setjmp.a
    ├── libunwind-setjmp.la
    ├── libunwind-setjmp.so -> libunwind-setjmp.so.0.0.0
    ├── libunwind-setjmp.so.0 -> libunwind-setjmp.so.0.0.0
    ├── libunwind-setjmp.so.0.0.0
    ├── libunwind.so -> libunwind.so.8.0.1
...                

Any potential suggestions on what I could try to forcefully create a shared library when I try to cross-compile?

Thank you in advance.

CodePudding user response:

Alright, I was able to find the answer.

TLDR:

./configure --enable-shared --prefix=/home/test/libunwind/arm_build --build=x86_64-pc-linux-gnu --host=aarch64-none-linux-gnu --libdir=/home/test/libunwind/arm_build/lib CC=/home/test/gcc-10.3/bin/aarch64-none-linux-gnu-gcc CXX=arm-none-linux-gnu-g   LDFLAGS="-L$PWD/src/.libs"

It seems like you should not specify the target if you are using a pre-built compiler (which I am with gcc 10.3) when running the configure.

I hope this will help others.

~/libunwind » tree arm_build 
arm_build                                                                                                                                                                         
├── include                                                                                                                                                                       
│   ├── libunwind-aarch64.h                                                                                                                                                       
│   ├── libunwind-common.h                                                                                                                                                        
│   ├── libunwind-coredump.h                                                                                                                                                      
│   ├── libunwind-dynamic.h                                                                                                                                                       
│   ├── libunwind.h
│   ├── libunwind-ptrace.h
│   └── unwind.h
└── lib
    ├── libunwind.a
    ├── libunwind-aarch64.a
    ├── libunwind-aarch64.la
    ├── libunwind-aarch64.so -> libunwind-aarch64.so.8.0.1
  • Related