mirror of
				https://github.com/hzyitc/openwrt-redmi-ax3000
				synced 2025-10-30 07:50:32 +08:00 
			
		
		
		
	tools: add options to optimize host binaries
Mains goals are: - reduce binary size of host tools; - reduce i/o load on build host; - increase performance of host tools being built. Signed-off-by: Konstantin Demin <rockdrilla@gmail.com> Link: https://github.com/openwrt/openwrt/pull/18659 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
		 Konstantin Demin
					Konstantin Demin
				
			
				
					committed by
					
						 Christian Marangi
						Christian Marangi
					
				
			
			
				
	
			
			
			 Christian Marangi
						Christian Marangi
					
				
			
						parent
						
							faef19c22c
						
					
				
				
					commit
					e8b470139c
				
			| @ -62,6 +62,60 @@ menuconfig DEVEL | |||||||
| 		  Compile all host host tools even if not needed. This is needed to prepare a | 		  Compile all host host tools even if not needed. This is needed to prepare a | ||||||
| 		  universal precompiled host tools archive to use in another buildroot. | 		  universal precompiled host tools archive to use in another buildroot. | ||||||
|  |  | ||||||
|  | 	menuconfig OPTIMIZE_HOST_TOOLS | ||||||
|  | 		bool "Host Tools compile options" if DEVEL | ||||||
|  |  | ||||||
|  | 		if OPTIMIZE_HOST_TOOLS | ||||||
|  |  | ||||||
|  | 		config HOST_FLAGS_OPT | ||||||
|  | 			string "Host Tools optimization flags" | ||||||
|  | 			default "-O2" | ||||||
|  | 			help | ||||||
|  | 			  Compiler flags which are used to build host tools. | ||||||
|  |  | ||||||
|  | 			  E.g.: "-O2", "-O3 -fno-tree-vectorize". | ||||||
|  |  | ||||||
|  | 			  Default is "-O2". | ||||||
|  |  | ||||||
|  | 		config HOST_TOOLS_STRIP | ||||||
|  | 			bool "Strip Host Tools" | ||||||
|  | 			help | ||||||
|  | 			  Instructs compiler/linker to use flags from HOST_FLAGS_STRIP | ||||||
|  | 			  in order to reduce binary size of host tools. | ||||||
|  |  | ||||||
|  | 		config HOST_FLAGS_STRIP | ||||||
|  | 			string "Host Tools compiler/linker flags for stripping symbols" | ||||||
|  | 			depends on HOST_TOOLS_STRIP | ||||||
|  | 			default "-Wl,-s" | ||||||
|  | 			help | ||||||
|  | 			  Compiler flags which are used to strip symbols from host tools. | ||||||
|  |  | ||||||
|  | 			  Each flag should be prefixed with "-Wl," string | ||||||
|  | 			  because compiler (GCC) passes this value to linker. | ||||||
|  |  | ||||||
|  | 			  Default is "-Wl,-s" which means "strip all symbols" - specifically, | ||||||
|  | 			  debug symbols and other symbols not needed for relocation processing. | ||||||
|  |  | ||||||
|  | 		comment "Host Tools miscellaneous flags" | ||||||
|  |  | ||||||
|  | 		config HOST_EXTRA_CFLAGS | ||||||
|  | 			string "Host Tools extra CFLAGS" | ||||||
|  | 			default "" | ||||||
|  |  | ||||||
|  | 		config HOST_EXTRA_CXXFLAGS | ||||||
|  | 			string "Host Tools extra CXXFLAGS" | ||||||
|  | 			default "" | ||||||
|  |  | ||||||
|  | 		config HOST_EXTRA_CPPFLAGS | ||||||
|  | 			string "Host Tools extra CPPFLAGS" | ||||||
|  | 			default "" | ||||||
|  |  | ||||||
|  | 		config HOST_EXTRA_LDFLAGS | ||||||
|  | 			string "Host Tools extra LDFLAGS" | ||||||
|  | 			default "" | ||||||
|  |  | ||||||
|  | 		endif | ||||||
|  |  | ||||||
| 	config BUILD_SUFFIX | 	config BUILD_SUFFIX | ||||||
| 		string "Build suffix to append to the target BUILD_DIR variable" if DEVEL | 		string "Build suffix to append to the target BUILD_DIR variable" if DEVEL | ||||||
| 		default "" | 		default "" | ||||||
|  | |||||||
							
								
								
									
										15
									
								
								rules.mk
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								rules.mk
									
									
									
									
									
								
							| @ -278,12 +278,19 @@ PKG_CONFIG:=$(STAGING_DIR_HOST)/bin/pkg-config | |||||||
|  |  | ||||||
| export PKG_CONFIG | export PKG_CONFIG | ||||||
|  |  | ||||||
|  | HOST_FLAGS_OPT:=$(call qstrip,$(CONFIG_HOST_FLAGS_OPT)) | ||||||
|  | HOST_FLAGS_STRIP:=$(call qstrip,$(CONFIG_HOST_FLAGS_STRIP)) | ||||||
|  | HOST_EXTRA_CFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_CFLAGS)) | ||||||
|  | HOST_EXTRA_CXXFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_CXXFLAGS)) | ||||||
|  | HOST_EXTRA_CPPFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_CPPFLAGS)) | ||||||
|  | HOST_EXTRA_LDFLAGS:=$(call qstrip,$(CONFIG_HOST_EXTRA_LDFLAGS)) | ||||||
|  |  | ||||||
| HOSTCC:=$(STAGING_DIR_HOST)/bin/gcc | HOSTCC:=$(STAGING_DIR_HOST)/bin/gcc | ||||||
| HOSTCXX:=$(STAGING_DIR_HOST)/bin/g++ | HOSTCXX:=$(STAGING_DIR_HOST)/bin/g++ | ||||||
| HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR_HOSTPKG)/include -I$(STAGING_DIR)/host/include) | HOST_CPPFLAGS:=$(strip -I$(STAGING_DIR_HOST)/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR_HOSTPKG)/include -I$(STAGING_DIR)/host/include) $(HOST_EXTRA_CPPFLAGS)) | ||||||
| HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS) | HOST_CFLAGS:=$(strip $(HOST_FLAGS_OPT) $(HOST_EXTRA_CFLAGS) $(HOST_CPPFLAGS) $(HOST_FLAGS_STRIP)) | ||||||
| HOST_CXXFLAGS:=$(HOST_CFLAGS) | HOST_CXXFLAGS:=$(strip $(HOST_CFLAGS) $(HOST_EXTRA_CXXFLAGS)) | ||||||
| HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib) | HOST_LDFLAGS:=$(strip -L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib) $(HOST_EXTRA_LDFLAGS) $(HOST_FLAGS_STRIP)) | ||||||
|  |  | ||||||
| BUILD_KEY=$(TOPDIR)/key-build | BUILD_KEY=$(TOPDIR)/key-build | ||||||
| BUILD_KEY_APK_SEC=$(TOPDIR)/private-key.pem | BUILD_KEY_APK_SEC=$(TOPDIR)/private-key.pem | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user