Skip to content

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

Open
ingomueller-net wants to merge 1 commit intosubstrait-io:mainfrom
ingomueller-net:fetch-content-compiler
Open

build: pass C/C++ compiler to FetchContent projects#145
ingomueller-net wants to merge 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.

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 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>
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.

1 participant