Cross-compiled libsupc++ for x86_64
Posted: Wed Nov 11, 2015 1:59 pm
Hello all,
I'm working on a x86_64 kernel. I've got usermode working and got a basic allocator for my applications. As my kernel is in C++, so will my usermode programs, and I would like to be able to use all C++ features there, including exceptions and the standard library. My current task is to add exceptions, RTTI, etc.
If I'm not mistaken I could simply link my programs with -lsupc++, if I'd have a working library. This should, I believe, implement those features.
But getting a good libsupc++.a doesn't really seem to work (I've tried a lot of things, including but not limited to http://wiki.osdev.org/Libsupcxx ).
Hence I'm trying to compile libsupc++.a on my Mac, to run on my x86_64 emulator.
For example, I ran the following commands:
And it creates a file ".libs/libsupc++.a". However, I can't link to this file:
The usual nm from Mac OS X does produce the expected output. So it seems to be compiling for the wrong target. Which isn't surprising from the make output (one example line):
I've tried several other methods. For example, it seemed reasonable to try to compile with the cross-compiled compilers:
But this won't even finish:
So, any ideas on how I could get a proper libsupc++ here?
Thanks in advance!
I'm working on a x86_64 kernel. I've got usermode working and got a basic allocator for my applications. As my kernel is in C++, so will my usermode programs, and I would like to be able to use all C++ features there, including exceptions and the standard library. My current task is to add exceptions, RTTI, etc.
If I'm not mistaken I could simply link my programs with -lsupc++, if I'd have a working library. This should, I believe, implement those features.
But getting a good libsupc++.a doesn't really seem to work (I've tried a lot of things, including but not limited to http://wiki.osdev.org/Libsupcxx ).
Hence I'm trying to compile libsupc++.a on my Mac, to run on my x86_64 emulator.
For example, I ran the following commands:
Code: Select all
export CC=/opt/local/bin/gcc-mp-4.9
export CXX=/opt/local/bin/g++-mp-4.9
export CPP=/opt/local/bin/cpp-mp-4.9
export LD=/opt/local/bin/gcc-mp-4.9
export PREFIX=/usr/local/cross
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH
cd /usr/local/cross/files/src/gcc-4.8.3/libstdc++-v3
CPP=/usr/local/cross/bin/x86_64-elf-cpp ./configure --host=x86_64-elf --prefix=/usr/local/cross --disable-hosted-libstdcxx --disable-nls
cd libsupc++
make
Code: Select all
$ /usr/local/cross/bin/x86_64-elf-nm .libs/libsupc++.a
/usr/local/cross/bin/x86_64-elf-nm: array_type_info.o: File format not recognized
/usr/local/cross/bin/x86_64-elf-nm: atexit_arm.o: File format not recognized
[...]
/usr/local/cross/bin/x86_64-elf-nm: vmi_class_type_info.o: File format not recognized
/usr/local/cross/bin/x86_64-elf-nm: vterminate.o: File format not recognized
Code: Select all
/bin/sh ../libtool --tag CXX --tag disable-shared --mode=compile /opt/local/bin/g++-mp-4.9 -I/usr/local/cross/files/src/gcc-4.8.3/libstdc++-v3/../libgcc -I/usr/local/cross/files/src/gcc-4.8.3/libstdc++-v3/include/x86_64-elf -I/usr/local/cross/files/src/gcc-4.8.3/libstdc++-v3/include -I/usr/local/cross/files/src/gcc-4.8.3/libstdc++-v3/libsupc++ -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=vterminate.lo -c -o vterminate.lo vterminate.cc
Code: Select all
export CC=/usr/local/cross/bin/x86_64-elf-gcc
export CXX=/usr/local/cross/bin/x86_64-elf-g++
export CPP=/usr/local/cross/bin/x86_64-elf-cpp
export LD=/usr/local/cross/bin/x86_64-elf-gcc
cd /usr/local/cross/files/src/gcc-4.8.3/libstdc++-v3
./configure --host=x86_64-elf --prefix=/usr/local/cross --disable-hosted-libstdcxx --disable-nls
Code: Select all
[...]
checking whether the /usr/local/cross/bin/x86_64-elf-gcc linker (/usr/local/cross/bin/x86_64-elf-gcc) supports shared libraries... no
checking dynamic linker characteristics... no
checking how to hardcode library paths into programs... unsupported
checking for shl_load... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Thanks in advance!