Skip to content

build: pass C/C++ compiler to FetchContent projects#145

Merged
ingomueller-net merged 1 commit intosubstrait-io:mainfrom
ingomueller-net:fetch-content-compiler
Apr 9, 2026
Merged

build: pass C/C++ compiler to FetchContent projects#145
ingomueller-net merged 1 commit intosubstrait-io:mainfrom
ingomueller-net:fetch-content-compiler

Conversation

@ingomueller-net
Copy link
Copy Markdown
Contributor

This PR passes the CMAKE_(C|CXX)_COMPILER variables from the current project to the projects fetched with FetchContent. By default, the compiler will be chosen from scratch, which may be the content of the CC or CXX variables or the system default. This is problematic because it may change depending on the evironment where the build is run -- not the configuration. Furthermore, if different compilers and LTO are used, the build may break.

@ingomueller-net ingomueller-net marked this pull request as ready for review March 30, 2026 19:05
ingomueller-net added a commit to ingomueller-net/substrait-mlir-contrib that referenced this pull request Mar 30, 2026
This PR removes a work-around I thought would fix a problem with sframes
I ran into on my machine leading to linker errors while compiling ANTLR
(a dependency of substrait-cpp). Turns out that the root cause is that
CMake uses the system default compiler for dependencies fetched with
`FetchContent`, which is g++ on my machine (which emits sframes), which
may then linked with compilation units compiled by a different compiler,
which may break of LTO is enabled. The short-term solution is to set the
`CC?  and `CXX` environment variables to the same values as
`CMAKE_*_COMPILER` when configuring. I have submitted a better mid-term
solution as substrait-io/substrait-cpp#145.

Signed-off-by: Ingo Müller <ingomueller@google.com>
ingomueller-net added a commit to ingomueller-net/substrait-mlir-contrib that referenced this pull request Mar 31, 2026
This PR removes a work-around I thought would fix a problem with sframes
I ran into on my machine leading to linker errors while compiling ANTLR
(a dependency of substrait-cpp). Turns out that the root cause is that
CMake uses the system default compiler for dependencies fetched with
`FetchContent`, which is g++ on my machine (which emits sframes), which
may then linked with compilation units compiled by a different compiler,
which may break of LTO is enabled. The short-term solution is to set the
`CC?  and `CXX` environment variables to the same values as
`CMAKE_*_COMPILER` when configuring. I have submitted a better mid-term
solution as substrait-io/substrait-cpp#145.

Signed-off-by: Ingo Müller <ingomueller@google.com>
ingomueller-net added a commit to ingomueller-net/substrait-mlir-contrib that referenced this pull request Mar 31, 2026
This PR removes a work-around I thought would fix a problem with sframes
I ran into on my machine leading to linker errors while compiling ANTLR
(a dependency of substrait-cpp). Turns out that the root cause is that
CMake uses the system default compiler for dependencies fetched with
`FetchContent`, which is g++ on my machine (which emits sframes), which
may then linked with compilation units compiled by a different compiler,
which may break of LTO is enabled. The short-term solution is to set the
`CC?  and `CXX` environment variables to the same values as
`CMAKE_*_COMPILER` when configuring. I have submitted a better mid-term
solution as substrait-io/substrait-cpp#145.

Signed-off-by: Ingo Müller <ingomueller@google.com>
ingomueller-net added a commit to ingomueller-net/substrait-mlir-contrib that referenced this pull request Mar 31, 2026
This PR removes a work-around I thought would fix a problem with sframes
I ran into on my machine leading to linker errors while compiling ANTLR
(a dependency of substrait-cpp). Turns out that the root cause is that
CMake uses the system default compiler for dependencies fetched with
`FetchContent`, which is g++ on my machine (which emits sframes), which
may then linked with compilation units compiled by a different compiler,
which may break of LTO is enabled. The short-term solution is to set the
`CC?  and `CXX` environment variables to the same values as
`CMAKE_*_COMPILER` when configuring. I have submitted a better mid-term
solution as substrait-io/substrait-cpp#145.

Signed-off-by: Ingo Müller <ingomueller@google.com>
ingomueller-net added a commit to ingomueller-net/substrait-mlir-contrib that referenced this pull request Apr 1, 2026
This PR removes a work-around I thought would fix a problem with sframes
I ran into on my machine leading to linker errors while compiling ANTLR
(a dependency of substrait-cpp). Turns out that the root cause is that
CMake uses the system default compiler for dependencies fetched with
`FetchContent`, which is g++ on my machine (which emits sframes), which
may then linked with compilation units compiled by a different compiler,
which may break of LTO is enabled. The short-term solution is to set the
`CC?  and `CXX` environment variables to the same values as
`CMAKE_*_COMPILER` when configuring. I have submitted a better mid-term
solution as substrait-io/substrait-cpp#145.

Signed-off-by: Ingo Müller <ingomueller@google.com>
ingomueller-net added a commit to ingomueller-net/substrait-mlir-contrib that referenced this pull request Apr 1, 2026
This PR removes a work-around I thought would fix a problem with sframes
I ran into on my machine leading to linker errors while compiling ANTLR
(a dependency of substrait-cpp). Turns out that the root cause is that
CMake uses the system default compiler for dependencies fetched with
`FetchContent`, which is g++ on my machine (which emits sframes), which
may then linked with compilation units compiled by a different compiler,
which may break of LTO is enabled. The short-term solution is to set the
`CC?  and `CXX` environment variables to the same values as
`CMAKE_*_COMPILER` when configuring. I have submitted a better mid-term
solution as substrait-io/substrait-cpp#145.

Signed-off-by: Ingo Müller <ingomueller@google.com>
ingomueller-net added a commit to substrait-io/substrait-mlir-contrib that referenced this pull request Apr 1, 2026
This PR removes a work-around I thought would fix a problem with sframes
I ran into on my machine leading to linker errors while compiling ANTLR
(a dependency of substrait-cpp). Turns out that the root cause is that
CMake uses the system default compiler for dependencies fetched with
`FetchContent`, which is g++ on my machine (which emits sframes), which
may then linked with compilation units compiled by a different compiler,
which may break of LTO is enabled. The short-term solution is to set the
`CC?  and `CXX` environment variables to the same values as
`CMAKE_*_COMPILER` when configuring. I have submitted a better mid-term
solution as substrait-io/substrait-cpp#145.

Signed-off-by: Ingo Müller <ingomueller@google.com>
This PR passes the `CMAKE_(C|CXX)_COMPILER` variables from the current
project to the projects fetched with `FetchContent`. By default, the
compiler will be chosen from scratch, which may be the content of the
`CC` or `CXX` variables or the system default. This is problematic
because it may change depending on the evironment where the build is run
-- not the configuration. Furthermore, if different compilers and LTO
are used, the build may break.

Signed-off-by: Ingo Müller <ingomueller@google.com>
@ingomueller-net ingomueller-net force-pushed the fetch-content-compiler branch from ad72cd6 to e62b4a6 Compare April 9, 2026 12:25
@ingomueller-net ingomueller-net merged commit 2ba68d6 into substrait-io:main Apr 9, 2026
4 checks passed
@ingomueller-net ingomueller-net deleted the fetch-content-compiler branch April 9, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants