Punit Agrawal <punitagra...@gmail.com> writes:

> The boost detection mechanism assumes that if a CROSS_PREFIX is
> specified the library has to be installed in
> "build/downloaded_packages/aarch64/boost/install" folder in the OSv
> sources folder.
>
> This is not the case when cross compiling on a distro that supports
> multiarch and the boost libraries are installed using distro provided
> packages.
>
> Fix this by relying on the compiler (native or cross) to provide the
> location of boost libraries in the first instance. If this fails to
> find the library location, then fallback to the hard coded path.
>
> With the changes, it is not possible to cross compile OSv using -
>
>      CROSS_PREFIX="aarch64-linux-gnu-"
>      ./scripts/build -j8 arch=aarch64 fs=rofs image=native-example
>
> provided libboost-system-dev for arm64 is installed in the system.
>
> Signed-off-by: Punit Agrawal <punitagra...@gmail.com>
> ---
>  Makefile | 38 ++++++++++++++++----------------------
>  1 file changed, 16 insertions(+), 22 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 66448a9be982..502e019a2f3b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1845,34 +1845,28 @@ else
>  endif
>  endif
>  
> -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)),)
> +        $(warning Unable to resolve libboost_system.a using $(CC))
> +        ifeq ($(arch),aarch64)
> +            $(warning Falling back to 
> build/downloaded_packages/aarch64/boost/install)
> +            aarch64_boostbase = 
> build/downloaded_packages/aarch64/boost/install
> +            ifeq (,$(wildcard $(aarch64_boostbase)))
> +                $(error Missing $(aarch64_boostbase) directory. Please run 
> "./scripts/download_aarch64_packages.py")
> +            endif
> +            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)
> +            INCLUDES += -isystem $(aarch64_boostbase)/usr/include
> +        else
>              $(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
> -ifeq ($(arch),aarch64)
> -    aarch64_boostbase = build/downloaded_packages/aarch64/boost/install
> -    ifeq (,$(wildcard $(aarch64_boostbase)))
> -        $(error Missing $(aarch64_boostbase) directory. Please run 
> "./scripts/download_aarch64_packages.py")
> -    endif
> -
> -    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
> -endif
>  endif
> -
>  boost-libs := $(boost-lib-dir)/libboost_system$(boost-mt).a
>  
>  objects += fs/nfs/nfs_null_vfsops.o

Turns out this patch needs rebasing onto latest changes from Waldek to
support user specified boost install. Not sure how I managed to miss
those - sorry for the noise.

With those patches, there's no need for the special casing of aarch64 -
the user can specify boost_dir. Let me send a new version with the
updated changes.

-- 
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 osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/87mtw5eciy.fsf%40stealth.

Reply via email to