x86 port
Add support for x86 (IA-32) architecture. Currently only for static linkage.
mlibc uses 64 bit structs for stat, 64 bit time and other 64 bit functions by default. Are structs relevant for these correct on x86? Also, we can't really test or verify anything without a Linux implementation, so that's nigh required
I agree with arsen here, I won't be merging until there are at least the static tests enabled. If they don't pass then the implementation is just incomplete.
Why do we check for __i686__, not __i386__?
What's the state of this port? Does it compile / work / can it be tested in some way?
What's the state of this port? Does it compile / work / can it be tested in some way?
I have a local version which passes most of the tests (fails on pthreads mostly). Currently I'm in the process of integrating it with the new codebase.
Ran abidiff in a clean, docker-based Ubuntu 22.04 environment. The abidiff checker still crashes.
Dockerfile
ARG UBUNTU_VER=latest
FROM ubuntu:${UBUNTU_VER} as env
RUN apt update
RUN apt install -y meson ninja-build make curl abigail-tools rsync git g++-10 file
WORKDIR /src
ARG ARCH=x86_64
RUN if [ ! -d /linux-headers ]; then \
case "${ARCH}" in \
"aarch64") LINUX_ARCH="arm64" ;; \
"riscv64") LINUX_ARCH="riscv" ;; \
"x86") LINUX_ARCH="i386" ;; \
*) LINUX_ARCH=${ARCH} ;; \
esac; \
mkdir linux-headers; \
curl -L https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.5.7.tar.xz | tar -xJ -C linux-headers --strip-components=1 && make -C linux-headers -j headers_install ARCH=$LINUX_ARCH INSTALL_HDR_PATH=/linux-headers; \
fi
ARG BASE_URL
ARG BRANCH_URL
RUN if [ ! -d mlibc-base ]; then git clone ${BASE_URL} mlibc-base; fi
RUN if [ ! -d mlibc-branch ]; then git clone ${BRANCH_URL} mlibc-branch; fi
ARG BRANCH
RUN git -C mlibc-branch checkout ${BRANCH}
FROM env as base
WORKDIR /src/mlibc-base
RUN meson --cross-file=ci/linux-${ARCH}.cross-file --buildtype=debugoptimized -Dlinux_kernel_headers=/linux-headers/include build
RUN ninja -C build
RUN DESTDIR=/root-base ninja -C build install
FROM env as branch
WORKDIR /src/mlibc-branch
RUN meson --cross-file=ci/linux-${ARCH}.cross-file --buildtype=debugoptimized -Dlinux_kernel_headers=/linux-headers/include build
RUN ninja -C build
RUN DESTDIR=/root-branch ninja -C build install
FROM env as final
WORKDIR /mlibc
COPY --from=env /src/mlibc-branch mlibc-branch/
COPY --from=base /root-base root-base/
COPY --from=branch /root-branch root-branch/
COPY abidiff.sh abidiff.sh
RUN chmod +x abidiff.sh
ENTRYPOINT /mlibc/abidiff.sh
Build command
docker build --build-arg ARCH=x86_64 --build-arg BASE_URL=https://github.com/managarm/mlibc.git --build-arg BRANCH_URL=https://github.com/FedorLap2006/mlibc.git --build-arg BRANCH=x86 --build-arg UBUNTU_VER=22.04 -t mlibc-abidiff:22_04-x86_5732d36a .
Output
==== RUNNING ABIDIFF... ====
root-base/./usr/local/lib/libm.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=6bbd02afa6d3165804b594c0fabbbbf857bdfdb4, with debug_info, not stripped
root-branch/./usr/local/lib/libm.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=6edb1a33183c6cb4194b85490c22314542ae0a0c, with debug_info, not stripped
root-base/./usr/local/lib/ld.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=15617b3414c7cba5ec4f97a7eeb9dc4fec261de9, with debug_info, not stripped
root-branch/./usr/local/lib/ld.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=75beac652786c701a50fb33359bd3d385a8db771, with debug_info, not stripped
Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
root-base/./usr/local/lib/libdl.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=13341344feff534cce35938899c7f2fe585c91f1, with debug_info, not stripped
root-branch/./usr/local/lib/libdl.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=fe0bc0c7246fefdcff06cef88aafb36626090bc3, with debug_info, not stripped
root-base/./usr/local/lib/libcrypt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7e13206412b288abc6c7e6b26946e2994952ec50, with debug_info, not stripped
root-branch/./usr/local/lib/libcrypt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=1a36de18244d58e42f6a3a35cf7b9c050968c753, with debug_info, not stripped
root-base/./usr/local/lib/librt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=efb8a3d6b8aa7681d187846b55cef6de440f0c41, with debug_info, not stripped
root-branch/./usr/local/lib/librt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=af69e628755e42be0de88d47797109a955b23508, with debug_info, not stripped
root-base/./usr/local/lib/libutil.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=a27e2d4683a7255071fb44fabee1a2911521416a, with debug_info, not stripped
root-branch/./usr/local/lib/libutil.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=030d96d2ae0d1268862bae98b528127e5f045c31, with debug_info, not stripped
root-base/./usr/local/lib/libc.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=10bac5419466c9745bcd667cff65bb4898c89c52, with debug_info, not stripped
root-branch/./usr/local/lib/libc.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=96d0138bee2ec990615157680e702367ec7355f7, with debug_info, not stripped
Functions changes summary: 0 Removed, 27 Changed (62 filtered out), 0 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added (1 filtered out) variable
Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info
27 functions with some indirect sub-type change:
[C] 'function int __sigsetjmp(__anonymous_struct__*, int)' at stdlib-stubs.cpp:57:1 has some indirect sub-type changes:
parameter 1 of type '__anonymous_struct__*' has sub-type changes:
in pointed to type 'struct {__mlibc_jmpbuf_register_state reg_state; int savesigs; sigset_t sigset;}' at setjmp.h:28:1:
type size hasn't changed
1 data member change:
type of 'sigset_t sigset' changed:
underlying type 'long int' changed:
entity changed from 'long int' to compatible type 'typedef uint64_t' at stdint.h:21:1
type name changed from 'long int' to 'unsigned long int'
type size hasn't changed
[C] 'function int epoll_pwait(int, epoll_event*, int, int, const sigset_t*)' at sys-epoll.cpp:19:1 has some indirect sub-type changes:
parameter 5 of type 'const sigset_t*' changed:
in pointed to type 'const sigset_t':
[C] 'function int getcontext(ucontext_t*)' at ucontext-stubs.cpp:4:1 has some indirect sub-type changes:
parameter 1 of type 'ucontext_t*' has sub-type changes:
in pointed to type 'typedef ucontext_t' at signal.h:333:1:
underlying type 'struct __ucontext' at signal.h:282:1 changed:
type size hasn't changed
1 data member changes (1 filtered):
'sigset_t uc_sigmask' has *some* difference - please report as a bug
[C] 'function int posix_spawn(pid_t* restrict, const char* restrict, const posix_spawn_file_actions_t*, const posix_spawnattr_t* restrict, char* const*, char* const*)' at spawn-stubs.cpp:191:1 has some indirect sub-type changes:
parameter 4 of type 'const posix_spawnattr_t* restrict' has sub-type changes:
in unqualified underlying type 'const posix_spawnattr_t*':
in pointed to type 'const posix_spawnattr_t':
in unqualified underlying type 'typedef posix_spawnattr_t' at spawn.h:21:1:
underlying type 'struct posix_spawnattr_t' at spawn.h:14:1 changed:
type size hasn't changed
2 data member changes:
'sigset_t __def' has *some* difference - please report as a bug
'sigset_t __mask' has *some* difference - please report as a bug
[C] 'function int posix_spawnattr_setsigdefault(posix_spawnattr_t* restrict, const sigset_t* restrict)' at spawn-stubs.cpp:277:1 has some indirect sub-type changes:
parameter 2 of type 'const sigset_t* restrict' changed:
abidiff: ../../src/abg-default-reporter.cc:375: virtual void abigail::comparison::default_reporter::report(const abigail::comparison::qualified_type_diff&, std::ostream&, const string&) const: Assertion `__abg_cond__' failed.
/mlibc/abidiff.sh: line 8: 26 Aborted abidiff --no-added-syms --suppr mlibc-branch/ci/abidiff_suppress.ini --hd1 root-base/usr/local/include/ --hd2 root-branch/usr/local/include/ root-{base,branch}/"$file"
root-base/./usr/local/lib/libresolv.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=616d8e261db6de58d9596c5f7774605ba99f953b, with debug_info, not stripped
root-branch/./usr/local/lib/libresolv.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=d61f5c26c3f14320e996140c4c725e999ddfb867, with debug_info, not stripped
root-base/./usr/local/lib/libpthread.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=321eb29f654c65400ff517fa28f935985e46d6a0, with debug_info, not stripped
root-branch/./usr/local/lib/libpthread.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=03bbd0e98dd2bb397aea7542b926a7130080247b, with debug_info, not stripped
==== CHECKING FOR EXTRA FILES... ====
SOME FILES/ABI DIFFER, SEE OUTPUT ABOVE
Update on the abidiff issue
It seems the issue is fixed in abidiff 2.4. That's what it gave me so far:
==== RUNNING ABIDIFF... ====
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/libm.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ba5657c65614ca6f0b60f17bf364c8097bcd4b88, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/libm.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ace7288b1d8157c970a24c9534b1bbdd4fe5ad4d, with debug_info, not stripped
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/ld.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=6a78f609bc93798aba7d21fe8d4fdcea4b231a9c, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/ld.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=8766055addc5d5636b1ee080ac7dbd265a71724f, with debug_info, not stripped
Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/libdl.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=b5a16d960ae9cae91db17f6a5178b933c81358b9, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/libdl.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=b8af1aa9b396eed1b8fb999c0b926a4b503cf819, with debug_info, not stripped
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/libcrypt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=661953abc54a00c1574efb4cfa2efc4de72fe53a, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/libcrypt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2360cf83ad0b4beed14149d6efaf0f364d816bee, with debug_info, not stripped
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/librt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=286c5306f218b1475cdcaf607f89225d0c81de5b, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/librt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e218037936568c920a1a62de716da2799c9d3bc7, with debug_info, not stripped
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/libutil.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=09f15521aa96321420046f5394263941e7dd5105, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/libutil.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=9f79028a75805d8c9c7a52e4eeb91eb6e52cc89e, with debug_info, not stripped
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/libc.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=f2a1fd4d6bae5cfe2b5956076ac7a7aecc44dc0d, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/libc.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=53ea8575a9c0ffbe73cab563b8613803c8604e6f, with debug_info, not stripped
Functions changes summary: 0 Removed, 27 Changed (62 filtered out), 0 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added (1 filtered out) variable
Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info
27 functions with some indirect sub-type change:
[C] 'function int __sigsetjmp(__anonymous_struct__*, int)' at stdlib-stubs.cpp:57:1 has some indirect sub-type changes:
parameter 1 of type '__anonymous_struct__*' has sub-type changes:
in pointed to type 'struct {__mlibc_jmpbuf_register_state reg_state; int savesigs; sigset_t sigset;}' at setjmp.h:28:1:
type size hasn't changed
1 data member change:
type of 'sigset_t sigset' changed:
underlying type 'long int' changed:
entity changed from 'long int' to compatible type 'typedef uint64_t' at stdint.h:21:1
type name changed from 'long int' to 'unsigned long int'
type size hasn't changed
[C] 'function int epoll_pwait(int, epoll_event*, int, int, const sigset_t*)' at sys-epoll.cpp:19:1 has some indirect sub-type changes:
[C] 'function int getcontext(ucontext_t*)' at ucontext-stubs.cpp:4:1 has some indirect sub-type changes:
parameter 1 of type 'ucontext_t*' has sub-type changes:
in pointed to type 'typedef ucontext_t' at signal.h:333:1:
underlying type 'struct __ucontext' at signal.h:282:1 changed:
type size hasn't changed
no data member changes (2 filtered);
[C] 'function int posix_spawn(pid_t* restrict, const char* restrict, const posix_spawn_file_actions_t*, const posix_spawnattr_t* restrict, char* const*, char* const*)' at spawn-stubs.cpp:191:1 has some indirect sub-type changes:
parameter 4 of type 'const posix_spawnattr_t* restrict' has sub-type changes:
in unqualified underlying type 'const posix_spawnattr_t*':
in pointed to type 'const posix_spawnattr_t':
in unqualified underlying type 'typedef posix_spawnattr_t' at spawn.h:21:1:
underlying type 'struct posix_spawnattr_t' at spawn.h:14:1 changed:
type size hasn't changed
no data member changes (2 filtered);
[C] 'function int posix_spawnattr_setsigdefault(posix_spawnattr_t* restrict, const sigset_t* restrict)' at spawn-stubs.cpp:277:1 has some indirect sub-type changes:
[C] 'function int posix_spawnattr_setsigmask(posix_spawnattr_t* restrict, const sigset_t* restrict)' at spawn-stubs.cpp:294:1 has some indirect sub-type changes:
[C] 'function int ppoll(pollfd*, nfds_t, const timespec*, const sigset_t*)' at poll.cpp:20:1 has some indirect sub-type changes:
[C] 'function int pselect(int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*)' at sys-select-stubs.cpp:48:1 has some indirect sub-type changes:
[C] 'function int pthread_attr_destroy(pthread_attr_t*)' at pthread-stubs.cpp:78:1 has some indirect sub-type changes:
parameter 1 of type 'pthread_attr_t*' has sub-type changes:
in pointed to type 'typedef pthread_attr_t' at pthread.h:81:1:
underlying type 'struct __mlibc_threadattr' at threads.h:38:1 changed:
type size hasn't changed
no data member change (1 filtered);
[C] 'function int pthread_attr_getsigmask_np(const pthread_attr_t* restrict, sigset_t* restrict)' at pthread-stubs.cpp:234:1 has some indirect sub-type changes:
[C] 'function int pthread_attr_setsigmask_np(pthread_attr_t* restrict, const sigset_t* restrict)' at pthread-stubs.cpp:248:1 has some indirect sub-type changes:
[C] 'function int pthread_sigmask(int, const sigset_t* restrict, sigset_t* restrict)' at posix_signal.cpp:18:1 has some indirect sub-type changes:
[C] 'function int sigaction(int, const sigaction* restrict, sigaction* restrict)' at posix_signal.cpp:45:1 has some indirect sub-type changes:
parameter 2 of type 'const sigaction* restrict' has sub-type changes:
in unqualified underlying type 'const sigaction*':
in pointed to type 'const sigaction':
in unqualified underlying type 'struct sigaction' at signal.h:253:1:
type size hasn't changed
no data member change (1 filtered);
[C] 'function int sigaddset(sigset_t*, int)' at sigset.cpp:16:1 has some indirect sub-type changes:
[C] 'function int sigdelset(sigset_t*, int)' at sigset.cpp:24:1 has some indirect sub-type changes:
[C] 'function int sigemptyset(sigset_t*)' at sigset.cpp:4:1 has some indirect sub-type changes:
[C] 'function int sigfillset(sigset_t*)' at sigset.cpp:9:1 has some indirect sub-type changes:
[C] 'function int sigisemptyset(const sigset_t*)' at posix_signal.cpp:136:1 has some indirect sub-type changes:
[C] 'function int sigismember(const sigset_t*, int)' at sigset.cpp:32:1 has some indirect sub-type changes:
[C] 'function int signalfd(int, const sigset_t*, int)' at sys-signalfd.cpp:8:1 has some indirect sub-type changes:
[C] 'function int sigpending(sigset_t*)' at posix_signal.cpp:115:1 has some indirect sub-type changes:
[C] 'function int sigprocmask(int, const sigset_t* restrict, sigset_t* restrict)' at signal-stubs.cpp:36:1 has some indirect sub-type changes:
[C] 'function int sigsuspend(const sigset_t*)' at posix_signal.cpp:10:1 has some indirect sub-type changes:
[C] 'function int sigtimedwait(const sigset_t* restrict, siginfo_t* restrict, const timespec* restrict)' at posix_signal.cpp:86:1 has some indirect sub-type changes:
[C] 'function int sigwait(const sigset_t* restrict, int* restrict)' at posix_signal.cpp:104:1 has some indirect sub-type changes:
[C] 'function int sigwaitinfo(const sigset_t* restrict, siginfo_t* restrict)' at posix_signal.cpp:99:1 has some indirect sub-type changes:
[C] 'function int usleep(useconds_t)' at unistd-stubs.cpp:949:1 has some indirect sub-type changes:
parameter 1 of type 'typedef useconds_t' changed:
underlying type 'typedef __mlibc_uint64' at types.h:7:1 changed:
entity changed from 'typedef __mlibc_uint64' to compatible type 'unsigned int'
type name changed from 'unsigned long int' to 'unsigned int'
type size changed from 64 to 32 (in bits)
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/libresolv.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ca0152e484b373fb0ea762b12d0692bbdd005f13, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/libresolv.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=b3cadb289ea9a39d3f42811b495ea60c55dbda5e, with debug_info, not stripped
root-base/./x86_64/usr/local/lib/x86_64-linux-gnu/libpthread.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=c4ed54738e0a788292dbd04471a91cd9ccfa0f47, with debug_info, not stripped
root-branch/./x86_64/usr/local/lib/x86_64-linux-gnu/libpthread.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=d637157c307464f421950079b2c103fc21e341ea, with debug_info, not stripped
==== CHECKING FOR EXTRA FILES... ====
SOME FILES/ABI DIFFER, SEE OUTPUT ABOVE
Rebased on current master.
Nice!