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

add x32 ABI support (x86_64 -mx32) #264

Closed
trofi opened this issue Jun 24, 2021 · 2 comments · Fixed by #273
Closed

add x32 ABI support (x86_64 -mx32) #264

trofi opened this issue Jun 24, 2021 · 2 comments · Fixed by #273

Comments

@trofi
Copy link
Contributor

trofi commented Jun 24, 2021

It's a forward of downstream https://bugs.gentoo.org/614374 report where users try to get libunwind built on x32 userland. libffi fails there as:

~/libunwind $ LANG=C make
Making all in src
make[1]: Entering directory '/root/libunwind/src'
make  all-am
make[2]: Entering directory '/root/libunwind/src'
depbase=`echo x86_64/Los-linux.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../include  -I../include -I../include/tdep-x86_64 -I. -D_GNU_SOURCE -DNDEBUG  -g -O2 -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT x86_64/Los-linux.lo -MD -MP -MF $depbase.Tpo -c -o x86_64/Los-linux.lo x86_64/Los-linux.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include/tdep-x86_64 -I. -D_GNU_SOURCE -DNDEBUG -g -O2 -fexceptions -Wall -Wsign-compare -D__EXTENSIONS__ -MT x86_64/Los-linux.lo -MD -MP -MF x86_64/.deps/Los-linux.Tpo -c x86_64/Los-linux.c  -fPIC -DPIC -o x86_64/.libs/Los-linux.o
In file included from x86_64/Los-linux.c:4:
x86_64/Gos-linux.c: In function '_ULx86_64_sigreturn':
x86_64/Gos-linux.c:141:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  141 |   struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr;
      |                           ^
x86_64/Gos-linux.c: Assembler messages:
x86_64/Gos-linux.c:149: Error: unsupported instruction `mov'
make[2]: *** [Makefile:3908: x86_64/Los-linux.lo] Error 1
make[2]: Leaving directory '/root/libunwind/src'
make[1]: *** [Makefile:2211: all] Error 2
make[1]: Leaving directory '/root/libunwind/src'
make: *** [Makefile:607: all-recursive] Error 1

x32 ABI (https://en.wikipedia.org/wiki/X32_ABI) is supported at least by gcc with -mx32 or when gcc is built with --host=x86_64-pc-linux-gnux32 (Gentoo uses both forms).

@kasperk81
Copy link
Contributor

@trofi, btw, coincidentally your IA64 crossdev solution helped me upstream this gentoo patch #262. #smallworld 😉

@kasperk81
Copy link
Contributor

PR is up: #273

On Ubuntu, I installed:

apt install libtool-bin automake autoconf g++ g++-multilib
git clone https://github.com/libunwind/libunwind
cd libunwind
# applied patch from PR #273
autoreconf -i
./configure CFLAGS=-mx32 CXXFLAGS=-mx32
make -j
make check -j

It built and got stuck in some tests but failing more tests.
If i git-clean and add CC=clang and CXX=clang++ then it also requires that patch to compile, but more tests are passing with clang. So it must be unrelated optimization reason, but the library builds:

$ file src/.libs/libunwind.so.8.0.1
src/.libs/libunwind.so.8.0.1: ELF 32-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=1e1c68f2c3dcea6e3008e8f16bd02e0d40ccca86, not stripped

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

Successfully merging a pull request may close this issue.

2 participants