From 97b7d13f6580495e0276f8a9689e4bb9e89b5342 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 3 Feb 2020 01:09:08 -0500 Subject: [PATCH] force cross compiler/cross compiling now that config.guess knows how to detect musl, it's possible when building on a musl-based system that $build will spuriously match $target, preventing the desired behavior of building as a cross compiler or as a cross-compiled native compiler. run config.guess and config.sub from the litecross makefile to check if $build is going to match $target, and if so, append junk to the libc/abi part of the $build tuple so that it no longer matches. --- litecross/Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/litecross/Makefile b/litecross/Makefile index d0fbe0c..33d1b79 100644 --- a/litecross/Makefile +++ b/litecross/Makefile @@ -86,8 +86,15 @@ ifneq ($(NATIVE),) HOST:=$(TARGET) endif +ifeq ($(BUILD),) +GUESS = $(shell cd $(GCC_SRCDIR) && ./config.guess) +TARGET_CANON = $(shell cd $(GCC_SRCDIR) && ./config.sub $(TARGET)) +BUILD = $(GUESS)$(if $(subst $(TARGET_CANON),,$(GUESS)),,xx) +endif + ifeq ($(HOST),) SYSROOT = /$(TARGET) +FULL_BINUTILS_CONFIG += --build=$(BUILD) --host=$(BUILD) FULL_GCC_CONFIG += --with-build-sysroot=$(CURDIR)/obj_sysroot \ AR_FOR_TARGET=$(PWD)/obj_binutils/binutils/ar \ AS_FOR_TARGET=$(PWD)/obj_binutils/gas/as-new \ @@ -98,6 +105,7 @@ FULL_GCC_CONFIG += --with-build-sysroot=$(CURDIR)/obj_sysroot \ RANLIB_FOR_TARGET=$(PWD)/obj_binutils/binutils/ranlib \ READELF_FOR_TARGET=$(PWD)/obj_binutils/binutils/readelf \ STRIP_FOR_TARGET=$(PWD)/obj_binutils/binutils/strip-new \ + --build=$(BUILD) --host=$(BUILD) \ # end FULL_MUSL_CONFIG += CC="$(XGCC)" LIBCC="../obj_gcc/$(TARGET)/libgcc/libgcc.a" MUSL_VARS = AR=../obj_binutils/binutils/ar RANLIB=../obj_binutils/binutils/ranlib @@ -108,8 +116,8 @@ obj_gcc/.lc_built: | obj_sysroot/.lc_libs obj_sysroot/.lc_headers obj_gcc/.lc_configured: obj_binutils/.lc_built else SYSROOT = / -FULL_BINUTILS_CONFIG += --host=$(HOST) -FULL_GCC_CONFIG += --host=$(HOST) +FULL_BINUTILS_CONFIG += --build=$(BUILD) --host=$(HOST) +FULL_GCC_CONFIG += --build=$(BUILD) --host=$(HOST) MUSL_VARS = endif