From fc1ca909d1b96a04ec63608d337f999d6284b1b2 Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Tue, 24 Jun 2025 04:49:45 -0500 Subject: [PATCH 01/13] Update Clang in MRBind to 20. --- scripts/mrbind/clang_version.txt | 2 +- scripts/mrbind/clang_version_msys2.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mrbind/clang_version.txt b/scripts/mrbind/clang_version.txt index 3c032078a4a2..209e3ef4b624 100644 --- a/scripts/mrbind/clang_version.txt +++ b/scripts/mrbind/clang_version.txt @@ -1 +1 @@ -18 +20 diff --git a/scripts/mrbind/clang_version_msys2.txt b/scripts/mrbind/clang_version_msys2.txt index f279294d9dc7..edd3c7621af1 100644 --- a/scripts/mrbind/clang_version_msys2.txt +++ b/scripts/mrbind/clang_version_msys2.txt @@ -1 +1 @@ -18.1.8-2 \ No newline at end of file +20.1.7-1 From 8b3bd5d8352475fd0376419068e1312c69e2f79e Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Tue, 24 Jun 2025 05:17:41 -0500 Subject: [PATCH 02/13] Try again. --- .github/workflows/config.yml | 1 + scripts/mrbind/common_compiler_parser_flags.txt | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index a44b7eb9f282..2c065faa906d 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -129,6 +129,7 @@ jobs: - 'scripts/install_apt_requirements.sh' - 'scripts/install_dnf_requirements.sh' - 'scripts/mrbind/install_deps_ubuntu.sh' + - 'scripts/mrbind/clang_version.txt' - 'thirdparty/!(install.bat|vcpkg/**)' - name: Filter Linux vcpkg paths diff --git a/scripts/mrbind/common_compiler_parser_flags.txt b/scripts/mrbind/common_compiler_parser_flags.txt index 845ff0e32730..0b8670327cb8 100644 --- a/scripts/mrbind/common_compiler_parser_flags.txt +++ b/scripts/mrbind/common_compiler_parser_flags.txt @@ -1,5 +1,3 @@ -std=c++23 -Wno-nonportable-include-path --Wno-enum-constexpr-conversion -Wno-deprecated-enum-enum-conversion --frelaxed-template-template-args From 88cf833f23ad8e3beb8ad0ee7f1f9d7d5f6f431d Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Tue, 24 Jun 2025 08:24:29 -0500 Subject: [PATCH 03/13] Try again with different Clang versions. --- .github/workflows/build-test-windows.yml | 2 +- .github/workflows/config.yml | 2 +- .github/workflows/pip-build.yml | 2 +- docker/ubuntu20Dockerfile | 2 +- docker/ubuntu22Dockerfile | 2 +- docker/ubuntu24Dockerfile | 2 +- scripts/mrbind/README-generating.md | 12 +++--- scripts/mrbind/generate.mk | 4 +- scripts/mrbind/install_deps_macos.sh | 4 +- scripts/mrbind/install_deps_ubuntu.sh | 3 +- scripts/mrbind/install_deps_windows_msys2.bat | 3 +- scripts/mrbind/install_mrbind_macos.sh | 4 +- scripts/mrbind/install_mrbind_ubuntu.sh | 3 +- scripts/mrbind/select_clang_version.sh | 37 +++++++++++++++++++ 14 files changed, 56 insertions(+), 26 deletions(-) create mode 100755 scripts/mrbind/select_clang_version.sh diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index 923c29fe5315..f70873b9d3aa 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -195,7 +195,7 @@ jobs: if: ${{inputs.mrbind}} shell: msys2 {0} run: | - ./scripts/mrbind/msys2_install_clang_ver.sh $(cat scripts/mrbind/clang_version_msys2.txt) + ./scripts/mrbind/msys2_install_clang_ver.sh $(scripts/mrbind/select_clang_version.sh) - name: Install Ninja for CMake if: ${{ matrix.build_system == 'CMake' }} diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 2c065faa906d..7728a3142616 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -129,7 +129,7 @@ jobs: - 'scripts/install_apt_requirements.sh' - 'scripts/install_dnf_requirements.sh' - 'scripts/mrbind/install_deps_ubuntu.sh' - - 'scripts/mrbind/clang_version.txt' + - 'scripts/mrbind/select_clang_version.sh' - 'thirdparty/!(install.bat|vcpkg/**)' - name: Filter Linux vcpkg paths diff --git a/.github/workflows/pip-build.yml b/.github/workflows/pip-build.yml index fb448aa728a5..8a34b24a6eea 100644 --- a/.github/workflows/pip-build.yml +++ b/.github/workflows/pip-build.yml @@ -269,7 +269,7 @@ jobs: - name: Install Clang in MSYS2 shell: msys2 {0} run: | - ./scripts/mrbind/msys2_install_clang_ver.sh $(cat scripts/mrbind/clang_version_msys2.txt) + ./scripts/mrbind/msys2_install_clang_ver.sh $(scripts/mrbind/select_clang_version.sh) - name: Build MRBind shell: cmd diff --git a/docker/ubuntu20Dockerfile b/docker/ubuntu20Dockerfile index 0116c0c86e8b..45afddecee3e 100644 --- a/docker/ubuntu20Dockerfile +++ b/docker/ubuntu20Dockerfile @@ -34,7 +34,7 @@ WORKDIR "/usr/local/lib/meshlib-thirdparty-lib/" COPY scripts/install_apt_requirements.sh scripts/install_apt_requirements.sh COPY scripts/mrbind/install_deps_ubuntu.sh scripts/mrbind/install_deps_ubuntu.sh -COPY scripts/mrbind/clang_version.txt scripts/mrbind/clang_version.txt +COPY scripts/mrbind/select_clang_version.sh scripts/mrbind/select_clang_version.sh COPY scripts/install_thirdparty.sh scripts/install_thirdparty.sh COPY scripts/patches scripts/patches COPY requirements requirements diff --git a/docker/ubuntu22Dockerfile b/docker/ubuntu22Dockerfile index 752e166cc588..433eef23fa77 100644 --- a/docker/ubuntu22Dockerfile +++ b/docker/ubuntu22Dockerfile @@ -34,7 +34,7 @@ WORKDIR "/usr/local/lib/meshlib-thirdparty-lib/" COPY scripts/install_apt_requirements.sh scripts/install_apt_requirements.sh COPY scripts/mrbind/install_deps_ubuntu.sh scripts/mrbind/install_deps_ubuntu.sh -COPY scripts/mrbind/clang_version.txt scripts/mrbind/clang_version.txt +COPY scripts/mrbind/select_clang_version.sh scripts/mrbind/select_clang_version.sh COPY scripts/install_thirdparty.sh scripts/install_thirdparty.sh COPY scripts/patches scripts/patches COPY requirements requirements diff --git a/docker/ubuntu24Dockerfile b/docker/ubuntu24Dockerfile index 33ce64962c9e..bc740db6e52c 100644 --- a/docker/ubuntu24Dockerfile +++ b/docker/ubuntu24Dockerfile @@ -35,7 +35,7 @@ WORKDIR "/usr/local/lib/meshlib-thirdparty-lib/" COPY scripts/install_apt_requirements.sh scripts/install_apt_requirements.sh COPY scripts/mrbind/install_deps_ubuntu.sh scripts/mrbind/install_deps_ubuntu.sh -COPY scripts/mrbind/clang_version.txt scripts/mrbind/clang_version.txt +COPY scripts/mrbind/select_clang_version.sh scripts/mrbind/select_clang_version.sh COPY scripts/install_thirdparty.sh scripts/install_thirdparty.sh COPY scripts/patches scripts/patches COPY requirements requirements diff --git a/scripts/mrbind/README-generating.md b/scripts/mrbind/README-generating.md index ac2d6e089180..5569cb87ddbc 100644 --- a/scripts/mrbind/README-generating.md +++ b/scripts/mrbind/README-generating.md @@ -28,7 +28,7 @@ Among other things, the scripts can do following: We use [MSYS2 CLANG64](https://www.msys2.org/docs/environments/) environment. Consult `install_deps_windows_msys2.bat` for the list of packages we install in it. - We don't use the latest Clang version, instead we download and install the version specified in `clang_version_msys2.txt`. + We don't use the latest Clang version, instead we download and install the version specified in `select_clang_version.sh`. * **Building MRBind:** @@ -45,7 +45,7 @@ Among other things, the scripts can do following: * **Installing dependencies:** - We want a certain version of Clang (see `clang_version.txt`), and since older versions of Ubuntu don't have it, we add Clang's repository: https://apt.llvm.org + We want a certain version of Clang (see `select_clang_version.sh`), and since older versions of Ubuntu don't have it, we add Clang's repository: https://apt.llvm.org And obviously we install some packages, see `install_deps_ubuntu.sh` for the list. @@ -55,7 +55,7 @@ Among other things, the scripts can do following: We build MRBind at `MeshLib/mrbind`, but you can build it [elsewhere](#less-common-flags) manually. - You might want to pass `-DClang_DIR=/usr/lib/cmake/clang-VERSION` (where `VERSION` is the one mentioned in `clang_version.txt`) if you have several versions of libclang installed, because otherwise CMake might pick an arbitrary one (apparently it picks the first one returned by globbing `clang-*`, which might not be the latest one). + You might want to pass `-DClang_DIR=/usr/lib/cmake/clang-VERSION` (where `VERSION` is the one mentioned in `select_clang_version.sh`) if you have several versions of libclang installed, because otherwise CMake might pick an arbitrary one (apparently it picks the first one returned by globbing `clang-*`, which might not be the latest one). Use `CC=clang-VERSION CXX=clang++-VERSION cmake ....` to build using Clang. Other compilers might work, but that's not guaranteed. @@ -67,14 +67,14 @@ Among other things, the scripts can do following: Homebrew must already be installed. - We install a certain version of Clang and libclang from it (see `clang_version.txt`), and also GNU Make and Gawk. MacOS has its own Make, but it's outdated. It seems to have Gawk, but we install our own just in case. + We install a certain version of Clang and libclang from it (see `select_clang_version.sh`), and also GNU Make and Gawk. MacOS has its own Make, but it's outdated. It seems to have Gawk, but we install our own just in case. What we install from Brew is the regular Clang, not Apple Clang (Apple's fork for Clang), because that is based on an outdated branch of Clang. You must run following to add the installed things to your PATH. On Arm Macs: ```sh export PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH" - export PATH="/opt/homebrew/opt/llvm/bin@VERSION:$PATH" # See the correct VERSION in `clang_version.txt`. + export PATH="/opt/homebrew/opt/llvm/bin@VERSION:$PATH" # See the correct VERSION in `select_clang_version.sh`. ``` And on x86 Macs the installation directory seems to be `/usr/local/...` instead of `/opt/homebrew/...`. @@ -123,7 +123,7 @@ Then generate the bindings: ### Selecting the compiler: -For simplicity, we compile the bindings with the same Clang that we use for parsing the code. (Consult `clang_version.txt` for the current version.) But you can override this using `CXX_FOR_BINDINGS`. +For simplicity, we compile the bindings with the same Clang that we use for parsing the code. (Consult `select_clang_version.sh` for the current version.) But you can override this using `CXX_FOR_BINDINGS`. **ABI compatibility:** Since MeshLib is compiled using a different compiler, we must ensure the two use the same ABI. `CXX_FOR_ABI` should be set to the compiler the ABI of which we're trying to match. (Defaults to `CXX` environment variable, or `g++` if not set.) At the moment, if `CXX_FOR_ABI` is GCC 13 or older or Clang 17 or older (note that Apple Clang uses a [different version numbering scheme](https://en.wikipedia.org/wiki/Xcode#Xcode_15.0_-_(since_visionOS_support)_2)), we pass `-fclang-abi-compat=17` to our Clang 18 or newer. This flag *disables* mangling `requires` constraints into function names. If we guess incorrectly, you'll get undefined references to functions with `requires` constraints on them. diff --git a/scripts/mrbind/generate.mk b/scripts/mrbind/generate.mk index 9f256e31d03d..79deaeddd5ce 100644 --- a/scripts/mrbind/generate.mk +++ b/scripts/mrbind/generate.mk @@ -156,10 +156,10 @@ MRBIND_EXE := $(MRBIND_SOURCE)/build/mrbind ifneq ($(IS_WINDOWS),) CXX_FOR_BINDINGS := clang++ else ifneq ($(IS_MACOS),) -CXX_FOR_BINDINGS := $(HOMEBREW_DIR)/opt/llvm@$(strip $(file <$(makefile_dir)clang_version.txt))/bin/clang++ +CXX_FOR_BINDINGS := $(HOMEBREW_DIR)/opt/llvm@$(call safe_shell,$(makefile_dir)select_clang_version.sh)/bin/clang++ else # Only on Ubuntu we don't want the default Clang version, as it can be outdated. Use the suffixed one. -CXX_FOR_BINDINGS := clang++-$(strip $(file <$(makefile_dir)clang_version.txt)) +CXX_FOR_BINDINGS := clang++-$(call safe_shell,$(makefile_dir)select_clang_version.sh) endif # Which C++ compiler we should try to match for ABI. diff --git a/scripts/mrbind/install_deps_macos.sh b/scripts/mrbind/install_deps_macos.sh index aa04ef12e4a7..8bb2719dc20c 100755 --- a/scripts/mrbind/install_deps_macos.sh +++ b/scripts/mrbind/install_deps_macos.sh @@ -4,10 +4,8 @@ # We assume `brew` is already installed. Automatic its installation is too much, # especially because of the conflicts that happen if several users install it. -# Read the Clang version from `clang_version.txt`. `xargs` trims the whitespace. -# Some versions of MacOS seem to lack `realpath`, so not using it here. SCRIPT_DIR="$(dirname "$BASH_SOURCE")" -CLANG_VER="$(cat $SCRIPT_DIR/clang_version.txt | xargs)" +CLANG_VER="$("$SCRIPT_DIR/select_clang_version.sh")" [[ $CLANG_VER ]] || (echo "Not sure what version of Clang to use." && false) brew update diff --git a/scripts/mrbind/install_deps_ubuntu.sh b/scripts/mrbind/install_deps_ubuntu.sh index b9965608d34d..ffdbe5392275 100755 --- a/scripts/mrbind/install_deps_ubuntu.sh +++ b/scripts/mrbind/install_deps_ubuntu.sh @@ -10,9 +10,8 @@ apt update # Install `xargs` because we need it below. apt install -y findutils -# Read the Clang version from `clang_version.txt`. `xargs` trims the whitespace. SCRIPT_DIR="$(realpath "$(dirname "$BASH_SOURCE")")" -CLANG_VER="$(cat $SCRIPT_DIR/clang_version.txt | xargs)" +CLANG_VER="$("$SCRIPT_DIR/select_clang_version.sh")" [[ $CLANG_VER ]] || (echo "Not sure what version of Clang to use." && false) # Add LLVM repositories if the required package is not accessible right now. diff --git a/scripts/mrbind/install_deps_windows_msys2.bat b/scripts/mrbind/install_deps_windows_msys2.bat index a1365c24e869..37c6932213a1 100644 --- a/scripts/mrbind/install_deps_windows_msys2.bat +++ b/scripts/mrbind/install_deps_windows_msys2.bat @@ -10,7 +10,6 @@ rem some other MSYS2 copy. setlocal if "%MSYS2_DIR%" == "" set MSYS2_DIR=C:\msys64_meshlib_mrbind -if "%CLANG_VER%" == "" set /p CLANG_VER=<%~dp0\clang_version_msys2.txt rem ------ Ensure MSYS2 is installed @@ -50,6 +49,6 @@ rem ------ Install needed packages call %MSYS2_DIR%\msys2_shell.cmd -no-start -defterm -clang64 -c "pacman -S --noconfirm --needed gawk make procps-ng $MINGW_PACKAGE_PREFIX-cmake" rem ------ Install a specific version of Clang -call %MSYS2_DIR%\msys2_shell.cmd -no-start -defterm -clang64 -c "'%~dp0'/msys2_install_clang_ver.sh %CLANG_VER%" +call %MSYS2_DIR%\msys2_shell.cmd -no-start -defterm -clang64 -c "'%~dp0'/msys2_install_clang_ver.sh $('%~dp0'/select_clang_version.sh)" endlocal diff --git a/scripts/mrbind/install_mrbind_macos.sh b/scripts/mrbind/install_mrbind_macos.sh index efcc559b8ded..ff0316638264 100755 --- a/scripts/mrbind/install_mrbind_macos.sh +++ b/scripts/mrbind/install_mrbind_macos.sh @@ -8,9 +8,7 @@ SCRIPT_DIR="$(dirname "$BASH_SOURCE")" [[ ${MRBIND_DIR:=} ]] || MRBIND_DIR="$SCRIPT_DIR/../../thirdparty/mrbind" -# Read the Clang version from `clang_version.txt`. `xargs` trims the whitespace. -# Some versions of MacOS seem to lack `realpath`, so not using it here. -CLANG_VER="$(cat "$SCRIPT_DIR/clang_version.txt" | xargs)" +CLANG_VER="$("$SCRIPT_DIR/select_clang_version.sh")" [[ ${CLANG_VER:=} ]] || (echo "Not sure what version of Clang to use." && false) cd "$MRBIND_DIR" diff --git a/scripts/mrbind/install_mrbind_ubuntu.sh b/scripts/mrbind/install_mrbind_ubuntu.sh index fa820c7a767e..ac02d135f18b 100755 --- a/scripts/mrbind/install_mrbind_ubuntu.sh +++ b/scripts/mrbind/install_mrbind_ubuntu.sh @@ -8,8 +8,7 @@ SCRIPT_DIR="$(realpath "$(dirname "$BASH_SOURCE")")" [[ -v MRBIND_DIR ]] || MRBIND_DIR="$(realpath "$SCRIPT_DIR/../../thirdparty/mrbind")" -# Read the Clang version from `clang_version.txt`. `xargs` trims the whitespace. -CLANG_VER="$(cat "$SCRIPT_DIR/clang_version.txt" | xargs)" +CLANG_VER="$("$SCRIPT_DIR/select_clang_version.sh")" [[ $CLANG_VER ]] || (echo "Not sure what version of Clang to use." && false) cd "$MRBIND_DIR" diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh new file mode 100755 index 000000000000..17f35fced303 --- /dev/null +++ b/scripts/mrbind/select_clang_version.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Returns the version of MSYS2 we want to use on each platform. + +set -euo pipefail + +# Windows, Clang installed via MSYS2. +if [[ $(uname -o) == Msys ]]; then + echo "20.1.7-1" + exit +fi + +UNAME_S=$(uname -s) + +# MacOS. +if [[ $UNAME_S == Darwin ]]; then + echo "20" + exit +fi + +# Linux +if [[ $UNAME_S == Linux ]]; then + # Is `Ubuntu <= 22.04`? + # Here we use `compgen -c` to not rely on `which` existing, since it's getting removed from some distros. + if compgen -c lsb_release >/dev/null 2>/dev/null && (lsb_release -rs; echo "22.04") | sort -rCV; then + # Here we need the outdated Clang because the old Boost doesn't compile on the new Clang, because of this change: https://github.com/llvm/llvm-project/issues/59036 + echo "18" + exit + fi + + # Any other linux + echo "20" + exit +fi + +echo "Unknown OS" >&2 +exit 1 From 9f24a5806d531c98d8a08f6a6c0ae3098d80bb49 Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Tue, 24 Jun 2025 09:30:23 -0500 Subject: [PATCH 04/13] Try again. --- scripts/mrbind/select_clang_version.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index 17f35fced303..94dff0de0214 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -21,8 +21,9 @@ fi # Linux if [[ $UNAME_S == Linux ]]; then # Is `Ubuntu <= 22.04`? - # Here we use `compgen -c` to not rely on `which` existing, since it's getting removed from some distros. - if compgen -c lsb_release >/dev/null 2>/dev/null && (lsb_release -rs; echo "22.04") | sort -rCV; then + # Here we use `type` to not rely on `which` existing, since it's getting removed from some distros. + # I also tried `compgen -c`, but that doesn't seem to work in our CI for some reason. + if type lsb_release >/dev/null 2>/dev/null && (lsb_release -rs; echo "22.04") | sort -rCV; then # Here we need the outdated Clang because the old Boost doesn't compile on the new Clang, because of this change: https://github.com/llvm/llvm-project/issues/59036 echo "18" exit From 9fdfbdf7fc58c85ae917fda90a8a5053e795fa30 Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Wed, 25 Jun 2025 06:27:44 -0500 Subject: [PATCH 05/13] Try again. --- requirements/ubuntu.txt | 1 + scripts/mrbind/select_clang_version.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/requirements/ubuntu.txt b/requirements/ubuntu.txt index dba913851a6c..7f96575ad88f 100644 --- a/requirements/ubuntu.txt +++ b/requirements/ubuntu.txt @@ -23,6 +23,7 @@ libtinyxml2-dev libturbojpeg0-dev libzip-dev libzstd-dev +lsb-release occt-misc pkg-config python3-venv diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index 94dff0de0214..1f4b64dba8db 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -21,9 +21,13 @@ fi # Linux if [[ $UNAME_S == Linux ]]; then # Is `Ubuntu <= 22.04`? + # Here we use `type` to not rely on `which` existing, since it's getting removed from some distros. - # I also tried `compgen -c`, but that doesn't seem to work in our CI for some reason. - if type lsb_release >/dev/null 2>/dev/null && (lsb_release -rs; echo "22.04") | sort -rCV; then + if ! type lsb_release >/dev/null 2>/dev/null; then + echo "`lsb_release` is not installed!" >&2 + fi + + if (lsb_release -rs; echo "22.04") | sort -rCV; then # Here we need the outdated Clang because the old Boost doesn't compile on the new Clang, because of this change: https://github.com/llvm/llvm-project/issues/59036 echo "18" exit From f0583d6b13cf334c767169a3fc893c90840af089 Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Wed, 25 Jun 2025 09:05:47 -0500 Subject: [PATCH 06/13] Fix the condition. --- scripts/mrbind/select_clang_version.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index 1f4b64dba8db..c0818dc472d1 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -20,14 +20,13 @@ fi # Linux if [[ $UNAME_S == Linux ]]; then - # Is `Ubuntu <= 22.04`? - # Here we use `type` to not rely on `which` existing, since it's getting removed from some distros. if ! type lsb_release >/dev/null 2>/dev/null; then echo "`lsb_release` is not installed!" >&2 fi - if (lsb_release -rs; echo "22.04") | sort -rCV; then + # Is `Ubuntu <= 22.04`? + if ! (lsb_release -rs; echo "22.04") | sort -CV; then # Here we need the outdated Clang because the old Boost doesn't compile on the new Clang, because of this change: https://github.com/llvm/llvm-project/issues/59036 echo "18" exit From 63fc52efe9b9f78c4d6858e2d01428ca78ea94f8 Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Thu, 26 Jun 2025 14:41:32 +0300 Subject: [PATCH 07/13] Again. --- scripts/mrbind/generate.mk | 6 ++--- scripts/mrbind/select_clang_version.sh | 36 +++++++++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/scripts/mrbind/generate.mk b/scripts/mrbind/generate.mk index 79deaeddd5ce..effb6fed0815 100644 --- a/scripts/mrbind/generate.mk +++ b/scripts/mrbind/generate.mk @@ -154,12 +154,12 @@ MRBIND_EXE := $(MRBIND_SOURCE)/build/mrbind # The C++ compiler. ifneq ($(IS_WINDOWS),) -CXX_FOR_BINDINGS := clang++ +CXX_FOR_BINDINGS := clang++ $(call safe_shell,$(makefile_dir)select_clang_version.sh --flags) else ifneq ($(IS_MACOS),) -CXX_FOR_BINDINGS := $(HOMEBREW_DIR)/opt/llvm@$(call safe_shell,$(makefile_dir)select_clang_version.sh)/bin/clang++ +CXX_FOR_BINDINGS := $(HOMEBREW_DIR)/opt/llvm@$(call safe_shell,$(makefile_dir)select_clang_version.sh)/bin/clang++ $(call safe_shell,$(makefile_dir)select_clang_version.sh --flags) else # Only on Ubuntu we don't want the default Clang version, as it can be outdated. Use the suffixed one. -CXX_FOR_BINDINGS := clang++-$(call safe_shell,$(makefile_dir)select_clang_version.sh) +CXX_FOR_BINDINGS := clang++-$(call safe_shell,$(makefile_dir)select_clang_version.sh) $(call safe_shell,$(makefile_dir)select_clang_version.sh --flags) endif # Which C++ compiler we should try to match for ABI. diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index c0818dc472d1..683cbe5ca852 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -1,12 +1,34 @@ #!/bin/bash -# Returns the version of MSYS2 we want to use on each platform. +# Returns the version of Clang that we want to use on the current platform. +# If you also pass `--flags`, we return the extra flags it needs. set -euo pipefail +if [[ $# > 1 ]]; then + echo 'Expected at most one argument: `--flags`, or nothing.' >&2 + exit +fi + +IS_FLAGS= +if [[ $# > 0 && $1 == "--flags" ]]; then + IS_FLAGS=1 +fi + + +CLANG_18=18 +CLANG_20=20 +CLANG_MSYS2=20.1.7-1 +if [[ $IS_FLAGS ]]; then + CLANG_18="-Wno-enum-constexpr-conversion -frelaxed-template-template-args" + CLANG_20= + CLANG_MSYS2= +fi + + # Windows, Clang installed via MSYS2. if [[ $(uname -o) == Msys ]]; then - echo "20.1.7-1" + echo $CLANG_MSYS2 exit fi @@ -14,7 +36,9 @@ UNAME_S=$(uname -s) # MacOS. if [[ $UNAME_S == Darwin ]]; then - echo "20" + # Clang 20 can't find the C++ standard library, so staying 18 for now. + # I didn't dig too deep here, and we have to maintain 18 anyway for Ubuntu 20.04 and 22.04 (see below for why that is). + echo $CLANG_18 exit fi @@ -26,14 +50,14 @@ if [[ $UNAME_S == Linux ]]; then fi # Is `Ubuntu <= 22.04`? - if ! (lsb_release -rs; echo "22.04") | sort -CV; then + if (lsb_release -rs; echo "22.04") | sort -CV; then # Here we need the outdated Clang because the old Boost doesn't compile on the new Clang, because of this change: https://github.com/llvm/llvm-project/issues/59036 - echo "18" + echo $CLANG_18 exit fi # Any other linux - echo "20" + echo $CLANG_20 exit fi From e22aa8ae2ad73e42a683f74d86d57172bb0eebd8 Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Thu, 26 Jun 2025 15:40:19 +0300 Subject: [PATCH 08/13] Again. --- scripts/mrbind/generate.mk | 12 +++++++++--- scripts/mrbind/select_clang_version.sh | 20 +++++--------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/scripts/mrbind/generate.mk b/scripts/mrbind/generate.mk index effb6fed0815..bfab34e6a87f 100644 --- a/scripts/mrbind/generate.mk +++ b/scripts/mrbind/generate.mk @@ -154,12 +154,12 @@ MRBIND_EXE := $(MRBIND_SOURCE)/build/mrbind # The C++ compiler. ifneq ($(IS_WINDOWS),) -CXX_FOR_BINDINGS := clang++ $(call safe_shell,$(makefile_dir)select_clang_version.sh --flags) +CXX_FOR_BINDINGS := clang++ else ifneq ($(IS_MACOS),) -CXX_FOR_BINDINGS := $(HOMEBREW_DIR)/opt/llvm@$(call safe_shell,$(makefile_dir)select_clang_version.sh)/bin/clang++ $(call safe_shell,$(makefile_dir)select_clang_version.sh --flags) +CXX_FOR_BINDINGS := $(HOMEBREW_DIR)/opt/llvm@$(call safe_shell,$(makefile_dir)select_clang_version.sh)/bin/clang++ else # Only on Ubuntu we don't want the default Clang version, as it can be outdated. Use the suffixed one. -CXX_FOR_BINDINGS := clang++-$(call safe_shell,$(makefile_dir)select_clang_version.sh) $(call safe_shell,$(makefile_dir)select_clang_version.sh --flags) +CXX_FOR_BINDINGS := clang++-$(call safe_shell,$(makefile_dir)select_clang_version.sh) endif # Which C++ compiler we should try to match for ABI. @@ -428,7 +428,13 @@ INPUT_GLOBS := *.h # `referenced by source/TempOutput/PythonBindings/x64/Release/binding.0.o:(public: __cdecl std::_Literal_zero::_Literal_zero(int))`. MRBIND_FLAGS := $(call load_file,$(makefile_dir)mrbind_flags.txt) MRBIND_FLAGS_FOR_EXTRA_INPUTS := $(call load_file,$(makefile_dir)mrbind_flags_for_helpers.txt) + COMPILER_FLAGS := $(ABI_COMPAT_FLAG) $(EXTRA_CFLAGS) $(call load_file,$(makefile_dir)common_compiler_parser_flags.txt) -I. -I$(DEPS_INCLUDE_DIR) -I$(makefile_dir)../../source +# Add some flags for old Clangs. +ifneq ($(filter 18 19,$(call safe_shell,$(CXX_FOR_BINDINGS) -dumpversion | cut -d. -f1)),) +COMPILER_FLAGS += -Wno-enum-constexpr-conversion -frelaxed-template-template-args +endif + COMPILER_FLAGS_LIBCLANG := $(call load_file,$(makefile_dir)parser_only_flags.txt) # Need whitespace before `$(MRBIND_SOURCE)` to handle `~` correctly. COMPILER := $(CXX_FOR_BINDINGS) $(subst $(lf), ,$(call load_file,$(makefile_dir)compiler_only_flags.txt)) -I $(MRBIND_SOURCE)/include -I$(makefile_dir) diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index 683cbe5ca852..55867db74aa7 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -5,25 +5,15 @@ set -euo pipefail -if [[ $# > 1 ]]; then - echo 'Expected at most one argument: `--flags`, or nothing.' >&2 +if [[ $# > 0 ]]; then + echo 'Expected no arguments.' >&2 exit fi -IS_FLAGS= -if [[ $# > 0 && $1 == "--flags" ]]; then - IS_FLAGS=1 -fi - CLANG_18=18 CLANG_20=20 CLANG_MSYS2=20.1.7-1 -if [[ $IS_FLAGS ]]; then - CLANG_18="-Wno-enum-constexpr-conversion -frelaxed-template-template-args" - CLANG_20= - CLANG_MSYS2= -fi # Windows, Clang installed via MSYS2. @@ -38,7 +28,7 @@ UNAME_S=$(uname -s) if [[ $UNAME_S == Darwin ]]; then # Clang 20 can't find the C++ standard library, so staying 18 for now. # I didn't dig too deep here, and we have to maintain 18 anyway for Ubuntu 20.04 and 22.04 (see below for why that is). - echo $CLANG_18 + echo 18 exit fi @@ -52,12 +42,12 @@ if [[ $UNAME_S == Linux ]]; then # Is `Ubuntu <= 22.04`? if (lsb_release -rs; echo "22.04") | sort -CV; then # Here we need the outdated Clang because the old Boost doesn't compile on the new Clang, because of this change: https://github.com/llvm/llvm-project/issues/59036 - echo $CLANG_18 + echo 18 exit fi # Any other linux - echo $CLANG_20 + echo 20 exit fi From e940727a4d33725eb40f68d481ceb29c828bcbd4 Mon Sep 17 00:00:00 2001 From: Egor Mikhaylov Date: Thu, 26 Jun 2025 16:45:45 +0300 Subject: [PATCH 09/13] Again. --- scripts/mrbind/select_clang_version.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index 55867db74aa7..477dc93cfe58 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -32,7 +32,7 @@ if [[ $UNAME_S == Darwin ]]; then exit fi -# Linux +# Linux. if [[ $UNAME_S == Linux ]]; then # Here we use `type` to not rely on `which` existing, since it's getting removed from some distros. if ! type lsb_release >/dev/null 2>/dev/null; then @@ -42,11 +42,19 @@ if [[ $UNAME_S == Linux ]]; then # Is `Ubuntu <= 22.04`? if (lsb_release -rs; echo "22.04") | sort -CV; then # Here we need the outdated Clang because the old Boost doesn't compile on the new Clang, because of this change: https://github.com/llvm/llvm-project/issues/59036 + # This is what is actually locking us to Clang 18 at the moment. Other platforms are using it for less scare reasons. echo 18 exit fi - # Any other linux + # Is any other ubuntu? + if [[ $(lsb_release -is) == Ubuntu ]]; then + # This is because teh stock spdlog and libfmt fail with `call to consteval function ... is not a constant expression` somewhere in the formatting logic. Hmm. + echo 18 + exit + fi + + # Any other linux. echo 20 exit fi From b7713c9e73556ad6114b89f29cd7ff84ba34fb84 Mon Sep 17 00:00:00 2001 From: Max Raiskii Date: Mon, 30 Jun 2025 00:43:06 +0300 Subject: [PATCH 10/13] test clang install --- scripts/mrbind/clang_version_msys2.txt | 2 +- scripts/mrbind/msys2_install_clang_ver.sh | 3 ++- scripts/mrbind/select_clang_version.sh | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/mrbind/clang_version_msys2.txt b/scripts/mrbind/clang_version_msys2.txt index edd3c7621af1..4dd4bf6e9475 100644 --- a/scripts/mrbind/clang_version_msys2.txt +++ b/scripts/mrbind/clang_version_msys2.txt @@ -1 +1 @@ -20.1.7-1 +20.1.5-1 diff --git a/scripts/mrbind/msys2_install_clang_ver.sh b/scripts/mrbind/msys2_install_clang_ver.sh index b63caf5b4184..fb6d754d79fa 100644 --- a/scripts/mrbind/msys2_install_clang_ver.sh +++ b/scripts/mrbind/msys2_install_clang_ver.sh @@ -7,6 +7,7 @@ # The packages are downloaded to `~/clang_downloads`. If they already exist, they aren't downloaded again. set -euo pipefail +set -x # Check that the number of arguments (`$#`) is one, and that the first argument (`$1`) isn't empty. [[ $# == 1 && $1 != "" ]] || (echo "Must specify one argument, the desired Clang version."; exit 1) @@ -21,7 +22,7 @@ DOWNLOAD_DIR="$(realpath ~/clang_downloads)" # This list should match what you'd see by installing `$MINGW_PACKAGE_PREFIX-{clang,clang-tools-extra}` and then looking at the list of packages (in `pacman -Q`). # But I could've included some unnecessary parts. -PACKAGES="$(echo $MINGW_PACKAGE_PREFIX-{clang,clang-libs,clang-tools-extra,compiler-rt,libc++,libunwind,lld,llvm,llvm-libs})" +PACKAGES="$(echo $MINGW_PACKAGE_PREFIX-{clang,clang-libs,clang-tools-extra,compiler-rt,libc++,libunwind,lld,llvm,llvm-libs,llvm-tools})" mkdir -p "$DOWNLOAD_DIR" diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index 477dc93cfe58..d6cbf96255fe 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -13,7 +13,7 @@ fi CLANG_18=18 CLANG_20=20 -CLANG_MSYS2=20.1.7-1 +CLANG_MSYS2=20.1.5-1 # Windows, Clang installed via MSYS2. From 22db78fae62f321dffb8af5f81423dad79369922 Mon Sep 17 00:00:00 2001 From: Max Raiskii Date: Mon, 30 Jun 2025 00:51:27 +0300 Subject: [PATCH 11/13] trigger build From f260e2c7365bb7150366226aac8acc5f655445c6 Mon Sep 17 00:00:00 2001 From: Max Raiskii Date: Mon, 30 Jun 2025 01:02:33 +0300 Subject: [PATCH 12/13] trigger build From 9397061de48418167b2af7855fd3d31b4f8b809b Mon Sep 17 00:00:00 2001 From: Max Raiskii Date: Mon, 30 Jun 2025 01:24:09 +0300 Subject: [PATCH 13/13] revert cmake version --- scripts/mrbind/clang_version_msys2.txt | 2 +- scripts/mrbind/select_clang_version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mrbind/clang_version_msys2.txt b/scripts/mrbind/clang_version_msys2.txt index 4dd4bf6e9475..edd3c7621af1 100644 --- a/scripts/mrbind/clang_version_msys2.txt +++ b/scripts/mrbind/clang_version_msys2.txt @@ -1 +1 @@ -20.1.5-1 +20.1.7-1 diff --git a/scripts/mrbind/select_clang_version.sh b/scripts/mrbind/select_clang_version.sh index d6cbf96255fe..477dc93cfe58 100755 --- a/scripts/mrbind/select_clang_version.sh +++ b/scripts/mrbind/select_clang_version.sh @@ -13,7 +13,7 @@ fi CLANG_18=18 CLANG_20=20 -CLANG_MSYS2=20.1.5-1 +CLANG_MSYS2=20.1.7-1 # Windows, Clang installed via MSYS2.