musl-cross-make
musl-cross-make copied to clipboard
Native compiler wrong multiarch
Hi.
I’ve built a cross compiler, x86_64-linux-musl
as target, then a native compiler using the cross one.
When running gcc -print-multiarch
on the native, I get i386-linux-gnu
.
Step to reproduce
Create a config.mak
with:
TARGET := x86_64-linux-musl
ifneq ($(NATIVE),)
OUTPUT := /foo
TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
PATH := $(TOP)/output/bin:/usr/bin
endif
MAKEFLAGS := --jobs=$(shell nproc)
COMMON_CONFIG += --disable-nls
GCC_CONFIG += --enable-languages=c,c++
GCC_CONFIG += --disable-libquadmath --disable-decimal-float
GCC_CONFIG += --disable-multilib
then
make
make install
make NATIVE=1
sudo make NATIVE=1 install
sudo ln -fs libc.so /foo/lib/ld-musl-x86_64.so.1 # https://github.com/richfelker/musl-cross-make/issues/82
sudo ln -s -t /lib $_
/foo/bin/gcc -print-multiarch
I discovered this bug when building python (./configure --build=x86_64-linux-musl
). Here is the relevant part from python’s configure
.
MULTIARCH=$($CC --print-multiarch 2>/dev/null)
[…]
if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
as_fn_error $? "internal configure error for the platform triplet, please file a bug report" "$LINENO" 5
fi
elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then
MULTIARCH=$PLATFORM_TRIPLET
fi
In the snippet, PLATFORM_TRIPLET
is x86_64-linux-musl
and MULTIARCH
is i386-linux-gnu
.
That being said, gcc -dumpmachine
does print the right x86_64-linux-musl
.
From https://gcc.gnu.org/install/configure.html:
--enable-multiarch: Specify whether to enable or disable multiarch support. The default is to check for glibc start files in a multiarch location, and enable it if the files are found. The auto detection is enabled for native builds, and for cross builds configured with --with-sysroot, and without --with-native-system-header-dir.
Based on the description in the GCC documentation, I don't see why multiarch support would be used without explicitly requesting it. Does adding --disable-multiarch
to GCC_CONFIG
fix the problem?
I was building with --disable-multiarch
while filling this issue. Note, the issue is only present in the native compiler. gcc -print-multiarch
on the cross one returns nothing.
And yes, --disable-multiarch
fixes the issue. It now returns nothing just like the cross one.
~~Also, why have you removed --disable-multilib
in 2954bf4 ?~~
this is now mandatory and always passed to configure
~~Details ?~~ EDIT: (7a6ed3a) Ignore this comment.
This bug can be solved with an argument to gcc. I don’t know if the argument should be used or not automatically by litecross when making a native compiler. I will close it for now.
I don't think this should be closed until --disable-multiarch
is committed.
I have also hit this issue when trying to build Python3 using x86_64-linux-musl-native.
Is there any update on a fix?