Thanks. I have tested it for both x64 and aarch64 with cross-compiling on 
Fedora, Ubuntu, and CentOS 7. t works. I probably have not exhausted all 
combinations though.

So I am committing it.

Waldek
On Friday, February 19, 2021 at 5:38:48 PM UTC-5 punit wrote:

> 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]>
> ---
> Makefile | 30 +++++++++++++++---------------
> modules/common.gmk | 20 ++++++++++----------
> 2 files changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 9d80f095a3c7..c4f08e4fb31d 100644
> --- 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
> index e0814b42414e..39c4c7ed2827 100644
> --- 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
> -- 
> 2.29.2
>
>

-- 
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/27f3a3bc-1e3d-4a04-b7d3-8a0f76f82200n%40googlegroups.com.

Reply via email to