bfgroup / b2

B2 makes it easy to build C++ projects, everywhere.
https://www.bfgroup.xyz/b2/
Boost Software License 1.0
75 stars 228 forks source link

Config checks using `address-model=32` in Linux don't use the right flags #368

Closed anarthal closed 4 months ago

anarthal commented 5 months ago

Make sure you completed the following tasks

Environment and version details

Please note: fail_if_no_openssl is a Boost.MySQL target that is not yet in the development branch.

Brief problem description

When building in Linux specifying address-model=32 in the command line, configuration checks seem to ignore the setting, which causes libraries to appear as not found.

Steps to reproduce the issue

  1. Create a repro/Jamfile file in the Boost root with the following, to force a config check on the OpenSSL library:
import ac ;
using openssl ;

alias test : requirements [ ac.check-library /openssl//ssl : : <build>no ] ;
  1. Run b2
root@ce785db6e1f3:~/boost-root# ./b2 address-model=32 toolset=clang repro
Performing configuration checks

    - ssl                      : no
...found 1 target...
  1. The output of config.log seems to imply that configuration checks are being run without the -m32 flag, which is causing the test executables to not build. Here's the log:
root@ce785db6e1f3:~/boost-root# cat bin.v2/config.log 
...found 14 targets...
...updating 12 targets...
clang-linux.compile.c++ bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/openssl/ssl_h.o
In file included from bin.v2/standalone/ac/openssl/ssl_h.cpp:1:
In file included from /usr/include/openssl/ssl.h:21:
/usr/include/openssl/macros.h:14:10: fatal error: 'openssl/opensslconf.h' file not found
#include <openssl/opensslconf.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

    "clang++"   -fvisibility-inlines-hidden -fPIC -pthread -O0 -fno-inline -Wall -g -fvisibility=hidden       -c -o "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/openssl/ssl_h.o" "bin.v2/standalone/ac/openssl/ssl_h.cpp"

...failed clang-linux.compile.c++ bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/openssl/ssl_h.o...

...updated 11 targets...

...failed updating 1 target...
   clang-linux.compile.c++ bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/openssl/ssl_h.o
...found 5 targets...
...updating 3 targets...
clang-linux.compile.c++ bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/main-ssl.o
clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssl
/usr/bin/ld: cannot find -lssl: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

    "clang++"    -o "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssl" -Wl,--start-group "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/main-ssl.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -lssl -Wl,--end-group -fPIC -pthread -g -fvisibility=hidden -fvisibility-inlines-hidden 

...failed clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssl...

...updated 2 targets...

...failed updating 1 target...
   clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssl
...found 5 targets...
...updating 3 targets...
clang-linux.compile.c++ bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/main-ssleay32.o
clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssleay32
/usr/bin/ld: cannot find -lssleay32: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

    "clang++"    -o "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssleay32" -Wl,--start-group "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/main-ssleay32.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -lssleay32 -Wl,--end-group -fPIC -pthread -g -fvisibility=hidden -fvisibility-inlines-hidden 

...failed clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssleay32...

...updated 2 targets...

...failed updating 1 target...
   clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/ssleay32
...found 5 targets...
...updating 5 targets...
clang-linux.compile.c++ bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/main-ssl.o
clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssl
/usr/bin/ld: cannot find -lssl: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

    "clang++"    -o "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssl" -Wl,--start-group "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/main-ssl.o"  -Wl,-Bstatic -lssl -Wl,-Bdynamic -lrt -Wl,--end-group -pthread -g -fvisibility=hidden -fvisibility-inlines-hidden 

...failed clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssl...

...updated 4 targets...

...failed updating 1 target...
   clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssl
...found 2 targets...
...updating 2 targets...
clang-linux.compile.c++ bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/main-ssleay32.o
clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssleay32
/usr/bin/ld: cannot find -lssleay32: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

    "clang++"    -o "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssleay32" -Wl,--start-group "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/main-ssleay32.o"  -Wl,-Bstatic -lssleay32 -Wl,-Bdynamic -lrt -Wl,--end-group -pthread -g -fvisibility=hidden -fvisibility-inlines-hidden 

...failed clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssleay32...

...updated 1 target...

...failed updating 1 target...
   clang-linux.link bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/link-static/threading-multi/visibility-hidden/ssleay32
...found 1 target...
...updating 1 target...
config-cache.write bin.v2/project-cache.jam

...updated 1 target...

Running the check "clang++" -fvisibility-inlines-hidden -fPIC -pthread -O0 -fno-inline -Wall -g -fvisibility=hidden -c -o "bin.v2/standalone/ac/clang-linux-16/debug/address-model-32/threading-multi/visibility-hidden/openssl/ssl_h.o" "bin.v2/standalone/ac/openssl/ssl_h.cpp" adding the -m32 flag succeeds.

  1. Note that libssl-dev:i386 is installed on the machine, but not libssl-dev:i686.
  2. Running ./b2 address-model=32 toolset=clang architecture=x86 repro succeeds.

Actual behavior summary

Expected behavior summary

We shouldn't need to specify architecture=x86 for config checks to succeed, since we don't need it for the code to build.

grisumbras commented 5 months ago

The problem is with deduction rules in https://github.com/boostorg/boost, the issue should be moved there.

pdimov commented 4 months ago

I merged the linked PR.