Skip to content

Commit 27b530f

Browse files
punitagrawalwkozaczuk
authored andcommitted
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]>
1 parent c6c6e0c commit 27b530f

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,22 +1847,20 @@ endif
18471847

18481848
#Allow user specify non-default location of boost
18491849
ifeq ($(boost_base),)
1850-
ifeq ($(CROSS_PREFIX),)
1851-
# link with -mt if present, else the base version (and hope it is multithreaded)
1852-
boost-mt := -mt
1850+
# link with -mt if present, else the base version (and hope it is multithreaded)
1851+
boost-mt := -mt
1852+
boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
1853+
ifeq ($(filter /%,$(boost-lib-dir)),)
1854+
boost-mt :=
18531855
boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
1854-
ifeq ($(filter /%,$(boost-lib-dir)),)
1855-
boost-mt :=
1856-
boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
1857-
ifeq ($(filter /%,$(boost-lib-dir)),)
1858-
$(error Error: libboost_system.a needs to be installed.)
1859-
endif
1860-
endif
1861-
# When boost_env=host, we won't use "-nostdinc", so the build machine's
1862-
# header files will be used normally. So we don't need to add anything
1863-
# special for Boost.
1864-
boost-includes =
1865-
else
1856+
endif
1857+
# When boost_env=host, we won't use "-nostdinc", so the build machine's
1858+
# header files will be used normally. So we don't need to add anything
1859+
# special for Boost.
1860+
boost-includes =
1861+
ifeq ($(filter /%,$(boost-lib-dir)),)
1862+
# If the compiler cannot find the boost library, for aarch64 we look in a
1863+
# special location before giving up.
18661864
ifeq ($(arch),aarch64)
18671865
aarch64_boostbase = build/downloaded_packages/aarch64/boost/install
18681866
ifeq (,$(wildcard $(aarch64_boostbase)))
@@ -1872,6 +1870,8 @@ ifeq ($(boost_base),)
18721870
boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a)))
18731871
boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt)
18741872
boost-includes = -isystem $(aarch64_boostbase)/usr/include
1873+
else
1874+
$(error Error: libboost_system.a needs to be installed.)
18751875
endif
18761876
endif
18771877
else

modules/common.gmk

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,14 @@ endif
123123
# Let us detect presence of boost headers and library
124124
# Allow user specify non-default location of boost
125125
ifeq ($(boost_base),)
126-
ifeq ($(CROSS_PREFIX),)
127-
boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so))
128-
ifeq ($(filter /%,$(boost-lib-dir)),)
129-
$(error Error: libboost_system.so needs to be installed.)
130-
endif
131-
# When boost_env=host, we won't use "-nostdinc", so the build machine's
132-
# header files will be used normally. So we don't need to add anything
133-
# special for Boost.
134-
boost-includes =
135-
else
126+
boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so))
127+
# When boost_env=host, we won't use "-nostdinc", so the build machine's
128+
# header files will be used normally. So we don't need to add anything
129+
# special for Boost.
130+
boost-includes =
131+
ifeq ($(filter /%,$(boost-lib-dir)),)
132+
# If the compiler cannot find the boost library, for aarch64 we look in a
133+
# special location before giving up.
136134
ifeq ($(arch),aarch64)
137135
aarch64_boostbase = $(src)/build/downloaded_packages/aarch64/boost/install
138136
ifeq (,$(wildcard $(aarch64_boostbase)))
@@ -142,6 +140,8 @@ ifeq ($(boost_base),)
142140
boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system.so)))
143141
LDFLAGS += -L$(boost-lib-dir)
144142
boost-includes = -isystem $(aarch64_boostbase)/usr/include
143+
else
144+
$(error Error: libboost_system.so needs to be installed.)
145145
endif
146146
endif
147147
else

0 commit comments

Comments
 (0)