From: Punit Agrawal <[email protected]> Committer: Waldemar Kozaczuk <[email protected]> Branch: master
Update boost library detection logic for cross compiling When cross compiling for aarch64 on an x86_64 host, the build system assumes that the boost library is placed in "build/downloaded_packages/aarch64/boost/install". This assumption works well on systems where cross libraries are not provided and need to be manually installed but does not support using multiarch distros that use standard location for cross libraries that the cross compiler can resolve. Update the boost library detection logic to first use the compiler to resolve the boost libraries (both during native and cross-builds) and failing that for aarch64 falling back to looking in the hardcoded path. Signed-off-by: Punit Agrawal <[email protected]> Message-Id: <[email protected]> --- diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -1847,22 +1847,20 @@ endif #Allow user specify non-default location of boost ifeq ($(boost_base),) - ifeq ($(CROSS_PREFIX),) - # link with -mt if present, else the base version (and hope it is multithreaded) - boost-mt := -mt + # link with -mt if present, else the base version (and hope it is multithreaded) + boost-mt := -mt + boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a)) + ifeq ($(filter /%,$(boost-lib-dir)),) + boost-mt := boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a)) - ifeq ($(filter /%,$(boost-lib-dir)),) - boost-mt := - boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a)) - ifeq ($(filter /%,$(boost-lib-dir)),) - $(error Error: libboost_system.a needs to be installed.) - endif - endif - # When boost_env=host, we won't use "-nostdinc", so the build machine's - # header files will be used normally. So we don't need to add anything - # special for Boost. - boost-includes = - else + endif + # When boost_env=host, we won't use "-nostdinc", so the build machine's + # header files will be used normally. So we don't need to add anything + # special for Boost. + boost-includes = + ifeq ($(filter /%,$(boost-lib-dir)),) + # If the compiler cannot find the boost library, for aarch64 we look in a + # special location before giving up. ifeq ($(arch),aarch64) aarch64_boostbase = build/downloaded_packages/aarch64/boost/install ifeq (,$(wildcard $(aarch64_boostbase))) @@ -1872,6 +1870,8 @@ ifeq ($(boost_base),) boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a))) boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt) boost-includes = -isystem $(aarch64_boostbase)/usr/include + else + $(error Error: libboost_system.a needs to be installed.) endif endif else diff --git a/modules/common.gmk b/modules/common.gmk --- a/modules/common.gmk +++ b/modules/common.gmk @@ -123,16 +123,14 @@ endif # Let us detect presence of boost headers and library # Allow user specify non-default location of boost ifeq ($(boost_base),) - ifeq ($(CROSS_PREFIX),) - boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so)) - ifeq ($(filter /%,$(boost-lib-dir)),) - $(error Error: libboost_system.so needs to be installed.) - endif - # When boost_env=host, we won't use "-nostdinc", so the build machine's - # header files will be used normally. So we don't need to add anything - # special for Boost. - boost-includes = - else + boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so)) + # When boost_env=host, we won't use "-nostdinc", so the build machine's + # header files will be used normally. So we don't need to add anything + # special for Boost. + boost-includes = + ifeq ($(filter /%,$(boost-lib-dir)),) + # If the compiler cannot find the boost library, for aarch64 we look in a + # special location before giving up. ifeq ($(arch),aarch64) aarch64_boostbase = $(src)/build/downloaded_packages/aarch64/boost/install ifeq (,$(wildcard $(aarch64_boostbase))) @@ -142,6 +140,8 @@ ifeq ($(boost_base),) boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system.so))) LDFLAGS += -L$(boost-lib-dir) boost-includes = -isystem $(aarch64_boostbase)/usr/include + else + $(error Error: libboost_system.so needs to be installed.) endif endif else -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000b2e52b05bc0e4fe6%40google.com.
