[Buildroot] [git commit] package/gcc/gcc-final: add a target variant in charge of target installation

Romain Naour romain.naour at smile.fr
Sat Sep 30 12:49:51 UTC 2023


commit: https://git.buildroot.net/buildroot/commit/?id=bfcddf057099d25e2f19aeb43c31af0f772006dc
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

This commit adds a target package "gcc-final", which is a target
package responsible for installing the gcc runtime libraries to
STAGING_DIR and TARGET_DIR. This task was so far done by the host
gcc-final package.

The motivation for splitting it up into a target package is to be able
to properly handle the licensing situation of GCC, where the host part
of GCC (the compiler itself) is under GPLv3, but the runtime libraries
on the target are under GPLv3-with-exception. So far, we were not
handling at all the license of gcc.

So what this commit does is:

 * Add a gcc-final target package, which is depended on by the
   toolchain-buildroot package, and which depends on
   host-gcc-final.

 * Moves to gcc-final the logic for installing target/staging
   libraries

Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
Signed-off-by: Romain Naour <romain.naour at smile.fr>
---
 package/gcc/Config.in                              |  3 ++
 package/gcc/gcc-final/gcc-final.mk                 | 42 +++++++++++-----------
 toolchain/toolchain-buildroot/Config.in            |  1 +
 .../toolchain-buildroot/toolchain-buildroot.mk     |  4 +--
 4 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/package/gcc/Config.in b/package/gcc/Config.in
new file mode 100644
index 0000000000..d2a26abba1
--- /dev/null
+++ b/package/gcc/Config.in
@@ -0,0 +1,3 @@
+config BR2_PACKAGE_GCC_FINAL
+	bool
+	default y if BR2_TOOLCHAIN_BUILDROOT
diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk
index ae6aedb2e7..bd18d9ea71 100644
--- a/package/gcc/gcc-final/gcc-final.mk
+++ b/package/gcc/gcc-final/gcc-final.mk
@@ -8,6 +8,11 @@ GCC_FINAL_VERSION = $(GCC_VERSION)
 GCC_FINAL_SITE = $(GCC_SITE)
 GCC_FINAL_SOURCE = $(GCC_SOURCE)
 
+GCC_FINAL_DEPENDENCIES = host-gcc-final
+GCC_FINAL_ADD_TOOLCHAIN_DEPENDENCY = NO
+GCC_FINAL_INSTALL_STAGING = YES
+
+GCC_FINAL_DL_SUBDIR = gcc
 HOST_GCC_FINAL_DL_SUBDIR = gcc
 
 HOST_GCC_FINAL_DEPENDENCIES = \
@@ -135,68 +140,63 @@ HOST_GCC_FINAL_POST_INSTALL_HOOKS += TOOLCHAIN_WRAPPER_INSTALL
 # -cc symlink to the wrapper is not created.
 HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
 
-HOST_GCC_FINAL_LIBS = libgcc_s libatomic
+GCC_FINAL_LIBS = libgcc_s libatomic
 
 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
-HOST_GCC_FINAL_USR_LIBS += libstdc++
+GCC_FINAL_USR_LIBS += libstdc++
 endif
 
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_DLANG),y)
-HOST_GCC_FINAL_USR_LIBS += libgdruntime libgphobos
+GCC_FINAL_USR_LIBS += libgdruntime libgphobos
 endif
 
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_FORTRAN),y)
-HOST_GCC_FINAL_USR_LIBS += libgfortran
+GCC_FINAL_USR_LIBS += libgfortran
 # fortran needs quadmath on x86 and x86_64
 ifeq ($(BR2_TOOLCHAIN_HAS_LIBQUADMATH),y)
-HOST_GCC_FINAL_USR_LIBS += libquadmath
+GCC_FINAL_USR_LIBS += libquadmath
 endif
 endif
 
 ifeq ($(BR2_GCC_ENABLE_OPENMP),y)
-HOST_GCC_FINAL_USR_LIBS += libgomp
+GCC_FINAL_USR_LIBS += libgomp
 endif
 
-HOST_GCC_FINAL_USR_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_LIBS))
+GCC_FINAL_USR_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_LIBS))
 
-define HOST_GCC_FINAL_INSTALL_STAGING_LIBS
-	$(foreach lib,$(HOST_GCC_FINAL_LIBS), \
+define GCC_FINAL_INSTALL_STAGING_CMDS
+	$(foreach lib,$(GCC_FINAL_LIBS), \
 		cp -dpf $(HOST_GCC_FINAL_GCC_LIB_DIR)/$(lib)* \
 			$(STAGING_DIR)/lib/
 	)
-	$(foreach lib,$(HOST_GCC_FINAL_USR_LIBS), \
+	$(foreach lib,$(GCC_FINAL_USR_LIBS), \
 		cp -dpf $(HOST_GCC_FINAL_GCC_LIB_DIR)/$(lib)* \
 			$(STAGING_DIR)/usr/lib/
 	)
 endef
 
 ifeq ($(BR2_STATIC_LIBS),)
-define HOST_GCC_FINAL_INSTALL_TARGET_LIBS
+define GCC_FINAL_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/lib $(TARGET_DIR)/usr/lib
-	$(foreach lib,$(HOST_GCC_FINAL_LIBS), \
+	$(foreach lib,$(GCC_FINAL_LIBS), \
 		cp -dpf $(HOST_GCC_FINAL_GCC_LIB_DIR)/$(lib).so* \
 			$(TARGET_DIR)/lib/
 	)
-	$(foreach lib,$(HOST_GCC_FINAL_USR_LIBS), \
+	$(foreach lib,$(GCC_FINAL_USR_LIBS), \
 		cp -dpf $(HOST_GCC_FINAL_GCC_LIB_DIR)/$(lib).so* \
 			$(TARGET_DIR)/usr/lib/
 	)
 endef
 endif
 
-define HOST_GCC_FINAL_INSTALL_LIBS
-	$(HOST_GCC_FINAL_INSTALL_STAGING_LIBS)
-	$(HOST_GCC_FINAL_INSTALL_TARGET_LIBS)
-endef
-HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_INSTALL_LIBS
-
 # coldfire is not working without removing these object files from libgcc.a
 ifeq ($(BR2_m68k_cf),y)
-define HOST_GCC_FINAL_M68K_LIBGCC_FIXUP
+define GCC_FINAL_M68K_LIBGCC_FIXUP
 	find $(STAGING_DIR) -name libgcc.a -print | \
 		while read t; do $(GNU_TARGET_NAME)-ar dv "$t" _ctors.o; done
 endef
-HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_M68K_LIBGCC_FIXUP
+GCC_FINAL_POST_INSTALL_STAGING_HOOKS += HOST_GCC_FINAL_M68K_LIBGCC_FIXUP
 endif
 
+$(eval $(generic-package))
 $(eval $(host-autotools-package))
diff --git a/toolchain/toolchain-buildroot/Config.in b/toolchain/toolchain-buildroot/Config.in
index 64f7892f98..0173f40d97 100644
--- a/toolchain/toolchain-buildroot/Config.in
+++ b/toolchain/toolchain-buildroot/Config.in
@@ -111,4 +111,5 @@ source "package/uclibc/Config.in"
 source "package/glibc/Config.in"
 source "package/binutils/Config.in.host"
 source "package/gcc/Config.in.host"
+source "package/gcc/Config.in"
 endif
diff --git a/toolchain/toolchain-buildroot/toolchain-buildroot.mk b/toolchain/toolchain-buildroot/toolchain-buildroot.mk
index 6da64b7c77..76862fa2e3 100644
--- a/toolchain/toolchain-buildroot/toolchain-buildroot.mk
+++ b/toolchain/toolchain-buildroot/toolchain-buildroot.mk
@@ -6,11 +6,11 @@
 
 BR_LIBC = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_LIBC))
 
-# Triggering the build of the host-gcc-final will automatically do the
+# Triggering the build of the gcc-final will automatically do the
 # build of binutils, uClibc, kernel headers and all the intermediate
 # gcc steps.
 
-TOOLCHAIN_BUILDROOT_DEPENDENCIES = host-gcc-final
+TOOLCHAIN_BUILDROOT_DEPENDENCIES = gcc-final
 
 TOOLCHAIN_BUILDROOT_ADD_TOOLCHAIN_DEPENDENCY = NO
 



More information about the buildroot mailing list