-
Notifications
You must be signed in to change notification settings - Fork 248
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
configure_make()
and meson()
don't work with hermetic toolchain
#1296
Comments
Relevant for meson: #1222 |
Seeing similar issues (apparently) at https://github.com/filmil/bazel_delib |
Not all configure based applications fail, I'm able to build some. FFmpeg is an unusual example because they've explicitly decided to ignore For meson I've found that my issue shows errors like this in the log:
I have an llvm toolchain configured with a sysroot, and my best guess is that because my sysroot is being passed with a relative path (instead of absolute) meson commands fail to find it. Here's an example command:
I tried hardcoding an absolute sysroot with a |
I can confirm that at least in my case the issue comes from having a relative sysroot, the following patch resolves my build issue: diff --git a/foreign_cc/meson.bzl b/foreign_cc/meson.bzl
index 9d4179a..e39886a 100644
--- a/foreign_cc/meson.bzl
+++ b/foreign_cc/meson.bzl
@@ -54,6 +54,15 @@ def _meson_impl(ctx):
)
return cc_external_rule_impl(ctx, attrs)
+def _absolutize_sysroot_flag(workspace_name, flags):
+ fixed_flags = []
+ for flag in flags:
+ if not flag.startswith("--sysroot="):
+ fixed_flags.append(flag)
+ continue
+ fixed_flags.append("--sysroot="+_absolutize(workspace_name, flag.lstrip("--sysroot=")))
+ return fixed_flags
+
def _create_meson_script(configureParameters):
"""Creates the bash commands for invoking commands to build meson projects
@@ -86,6 +95,9 @@ def _create_meson_script(configureParameters):
copts = (ctx.fragments.cpp.copts + ctx.fragments.cpp.conlyopts + getattr(ctx.attr, "copts", [])) or []
cxxopts = (ctx.fragments.cpp.copts + ctx.fragments.cpp.cxxopts + getattr(ctx.attr, "copts", [])) or []
+ copts = _absolutize_sysroot_flag(ctx.workspace_name, copts)
+ cxxopts = _absolutize_sysroot_flag(ctx.workspace_name, cxxopts)
+
if copts:
script.append("##export_var## CFLAGS \"{} ${{CFLAGS:-}}\"".format(" ".join(copts).replace("\"", "'")))
if cxxopts:
@@ -93,7 +105,8 @@ def _create_meson_script(configureParameters):
flags = get_flags_info(ctx)
if flags.cxx_linker_executable:
- script.append("##export_var## LDFLAGS \"{} ${{LDFLAGS:-}}\"".format(" ".join(flags.cxx_linker_executable).replace("\"", "'")))
+ ldflags = _absolutize_sysroot_flag(ctx.workspace_name, flags.cxx_linker_executable)
+ script.append("##export_var## LDFLAGS \"{} ${{LDFLAGS:-}}\"".format(" ".join(ldflags).replace("\"", "'")))
script.append("##export_var## CMAKE {}".format(attrs.cmake_path))
script.append("##export_var## NINJA {}".format(attrs.ninja_path))
|
@voxeljorge I created #1303 to solve the issue with the relative sysroot similar to what is done for other foreign tools. |
@mering I can confirm that your PR fixes my build as well. I am not partial to the fix but I definitely would like to see one merged in |
See #1295 for a reproduction example.
Both
configure()
andmeson()
don't seem to detect the hermetic toolchain and fail with errors likeC compiler cannot create executables
.The text was updated successfully, but these errors were encountered: