Skip to content

Commit

Permalink
Update boost library detection logic for cross compiling
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
punitagrawal authored and wkozaczuk committed Feb 24, 2021
1 parent c6c6e0c commit 27b530f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions modules/common.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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
Expand Down

0 comments on commit 27b530f

Please sign in to comment.