Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap procedure writes to source directory #339

Closed
iskunk opened this issue Sep 28, 2023 · 1 comment
Closed

Bootstrap procedure writes to source directory #339

iskunk opened this issue Sep 28, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@iskunk
Copy link

iskunk commented Sep 28, 2023

This issue was originally reported against bootstorg/build, but at that project's request has been transferred here.

Environment and version details

  • Operating System+version: Red Hat Enterprise Linux 8.8
  • Compiler+version: GCC 7
  • Shell: Bash
  • B2 Version: Bundled with Boost 1.83.0
  • B2 Configuration: N/A

Problem description

If the source tree (/tmp/boost_1_83_0/ in this example) is read-only, and we operate from a separate writable build directory (/tmp/boost-build/), then guessing the toolset fails as follows:

skunk@darkstar:/tmp/boost-build$ /tmp/boost_1_83_0/tools/build/src/engine/build.sh --verbose --guess-toolset
> g++ -x c++ -std=c++11  check_cxx11.cpp
/usr/bin/ld: cannot open output file a.out: Permission denied
collect2: error: ld returned 1 exit status
> g++ -x c++ -std=c++11 -D_GNU_SOURCE  check_cxx11.cpp
/usr/bin/ld: cannot open output file a.out: Permission denied
collect2: error: ld returned 1 exit status
> g++ -x c++ -std=c++11 -pthread  check_cxx11.cpp
/usr/bin/ld: cannot open output file a.out: Permission denied
collect2: error: ld returned 1 exit status
> clang++ -x c++ -std=c++11  check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: clang++: not found
> xlC_r   check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: xlC_r: not found
> pgc++ -std=c++11  check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: pgc++: not found
> pathCC   check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: pathCC: not found
> como   check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: como: not found
> bc++ -tC -q  check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: bc++: not found
> aCC -AA  check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: aCC: not found
> /opt/SUNWspro/bin/CC -std=c++11  check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: /opt/SUNWspro/bin/CC: not found
> cxx   check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: cxx: not found
> cpp   check_cxx11.cpp
cc1plus: fatal error: opening output file check_cxx11.cpp: Permission denied
compilation terminated.
> CC   check_cxx11.cpp
/tmp/boost_1_83_0/tools/build/src/engine/build.sh: 120: CC: not found

Could not find a suitable toolset.

You can specify the toolset as the argument, i.e.:
    ./build.sh [options] gcc

Toolsets supported by this script are:
    acc, clang, como, gcc, intel-darwin, intel-linux, kcc, kylix, mipspro,
    pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp

For any toolset you can override the path to the compiler with the '--cxx'
option. You can also use additional flags for the compiler with the
'--cxxflags' option.

A special toolset; cxx, is available which is used as a fallback when a more
specific toolset is not found and the cxx command is detected. The 'cxx'
toolset will use the '--cxx' and '--cxxflags' options, if present.

Options:
    --help                  Show this help message.
    --verbose               Show messages about what this script is doing.
    --debug                 Build b2 with debug information, and no
                            optimizations.
    --guess-toolset         Print the toolset we can detect for building.
    --cxx=CXX               The compiler exec to use instead of the detected
                            compiler exec.
    --cxxflags=CXXFLAGS     The compiler flags to use in addition to the
                            flags for the detected compiler.

If I make the source tree writable, then the same command succeeds:

skunk@darkstar:/tmp/boost-build$ /tmp/boost_1_83_0/tools/build/src/engine/build.sh --verbose --guess-toolset
> g++ -x c++ -std=c++11  check_cxx11.cpp
gcc

The configuration and build procedure must not write to the source tree in any way. Not only could the source tree be mounted read-only in one of various ways (NFS, Docker volume mount, ISO/SquashFS image, etc.), source tree timestamps are often used to set SOURCE_DATE_EPOCH in reproducible builds and writing to the source tree wrecks that.

Whatever scratch space is needed by these scripts should come from the build directory or $TMPDIR.

@iskunk iskunk added the bug Something isn't working label Sep 28, 2023
@grafikrobot
Copy link
Member

It is really difficult to provide an out-of-source build of B2 that works across the various compilers and operating systems. Hence it has never been attempted. Nor is likely to be attempted. If your goal is to build Boost in an out-of-source manner my suggestion would be to build B2 separately, i.e. copy it to a writable location, then install it. And use that installed version for building Boost. Note that the current version of B2 should work to build any version of Boost from 1.66 onward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants