diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-02-06 17:41:36 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-02-06 17:42:02 +0100 |
commit | 5b65a0df0a45fa4fa5a38e6927acabe0e6855fa1 (patch) | |
tree | ad162468333eb6f29584a99756f4b5b37d9e0924 | |
parent | c2234f3421b3caec39bed6a0b65dcdbc5c336a6b (diff) |
Add support for bootstrapping with custom compiler (toolchain) and flags.
-rwxr-xr-x | bootstrap.sh | 6 | ||||
-rw-r--r-- | src/configure.cc | 13 | ||||
-rwxr-xr-x | test/suite/test.sh | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/bootstrap.sh b/bootstrap.sh index d10f54b..4dd57ae 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,12 +1,12 @@ #!/bin/sh set -e -: ${CXX:=g++} +: ${CXX:=c++} : ${BUILDDIR:=build} echo "Bootstrapping..." -$CXX -std=c++20 -Wall -O3 -Isrc -pthread src/bootstrap.cc ctor.cc -o ctor +$CXX $LDFLAGS $CXXFLAGS -std=c++20 -Wall -O3 -Isrc -pthread src/bootstrap.cc ctor.cc -o ctor ./ctor -$CXX -std=c++20 -Wall -O3 -Isrc -pthread ctor.cc test/ctor.cc -L$BUILDDIR -lctor -o ctor +$CXX $LDFLAGS $CXXFLAGS -std=c++20 -Wall -O3 -Isrc -pthread ctor.cc test/ctor.cc -L$BUILDDIR -lctor -o ctor ./ctor configure --ctor-includedir=src --ctor-libdir=$BUILDDIR --build-dir=$BUILDDIR echo "Done. Now run ./ctor to (re)build." diff --git a/src/configure.cc b/src/configure.cc index ff4f24d..a43152f 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -31,7 +31,15 @@ const ctor::configuration& __attribute__((weak)) ctor::get_configuration() static bool initialised{false}; if(!initialised) { - cfg.build_toolchain = getToolChain(cfg.get(ctor::cfg::build_cxx, "/usr/bin/g++")); + std::string cxx_prog{"c++"}; + auto cxx_env = std::getenv("CXX"); + if(cxx_env) + { + cxx_prog = cxx_env; + } + + cfg.build_toolchain = getToolChain(cfg.get(ctor::cfg::build_cxx, cxx_prog)); + initialised = true; } return cfg; @@ -69,7 +77,8 @@ bool ctor::configuration::has(const std::string& key) const return tools.find(key) != tools.end(); } -std::string ctor::configuration::get(const std::string& key, const std::string& default_value) const +std::string ctor::configuration::get(const std::string& key, + const std::string& default_value) const { if(key == ctor::cfg::ctor_includedir && ctor::includedir) { diff --git a/test/suite/test.sh b/test/suite/test.sh index c112351..fe5d696 100755 --- a/test/suite/test.sh +++ b/test/suite/test.sh @@ -26,7 +26,7 @@ echo "** ctor_files/ctor.cc.base" cp ctor_files/ctor.cc.base ctor.cc # Compile bootstrap binary -$CXX -pthread -std=c++20 -L${CTORDIR} -lctor -I../../src ctor.cc -o ctor || fail ${LINENO} +$CXX -pthread $LDFLAGS $CXXFLAGS -std=c++20 -L${CTORDIR} -lctor -I../../src ctor.cc -o ctor || fail ${LINENO} # No build files should have been created yet [ -d ${BUILDDIR} ] && fail ${LINENO} |