Skip to content

Cross compiling gmp fails under WSL2 (Ubuntu) #16

@ChristianHerget

Description

@ChristianHerget

Issue

Config fails to detect executable suffix:

cd build-gmp && /home/christianher/tricore-gcc-toolchain/build-win32/gmp-6.2.1/configure \
        --prefix=/home/christianher/gcc-win32/deps \
        --host=x86_64-w64-mingw32 \
        --disable-assembly \
        --enable-static \
        --disable-shared \
        CFLAGS="-O2 -g" \
        CXXFLAGS="-O2 -g" \
        LDFLAGS=""
checking build system type... nehalem-pc-linux-gnu
checking host system type... x86_64-w64-mingw32
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-w64-mingw32-strip... x86_64-w64-mingw32-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=64
checking compiler x86_64-w64-mingw32-gcc -O2 -g ... yes
checking compiler x86_64-w64-mingw32-gcc -O2 -g  has long long... yes
checking for x86_64-w64-mingw32-gcc... x86_64-w64-mingw32-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-w64-mingw32-gcc accepts -g... yes
checking for x86_64-w64-mingw32-gcc option to accept ISO C89... none needed
checking whether x86_64-w64-mingw32-gcc understands -c and -o together... yes
checking for x86_64-w64-mingw32-gcc option to accept ISO C99... none needed
checking how to run the C preprocessor... x86_64-w64-mingw32-gcc -E
checking build system compiler x86_64-w64-mingw32-gcc... yes
checking for build system preprocessor... x86_64-w64-mingw32-gcc -E
checking for build system executable suffix... configure: error: Cannot determine executable suffix
make: *** [Makefile:148: stamps/build-gmp] Error 1

Workaround

Modify top level Makefile. Add CC, CC_FOR_BUILD and CPP_FOR_BUILD as shown below:

stamps/build-gmp: $(GMP_SRCDIR)
	rm -rf $@ $(notdir $@)
	mkdir $(notdir $@)
	cd $(notdir $@) && $</configure \
		--prefix=$(INSTALL_DIR)/deps \
		$(CONFIGURE_HOST) \
		--disable-assembly \
		--enable-static \
		--disable-shared \
		CC=x86_64-w64-mingw32-gcc \
		CC_FOR_BUILD=gcc \
		CPP_FOR_BUILD='gcc -E' \
		CFLAGS="$(CFLAGS)" \
		CXXFLAGS="$(CXXFLAGS)" \
		LDFLAGS="$(LDFLAGS)"
	$(MAKE) -C $(notdir $@)
	$(MAKE) -C $(notdir $@) install
	mkdir -p $(dir $@) && touch $@

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions