Skip to content

Instantly share code, notes, and snippets.

@0x2Adr1
Created February 5, 2023 14:28
Show Gist options
  • Save 0x2Adr1/51635421f64d6de8cbb14dbf40a27a4e to your computer and use it in GitHub Desktop.
Save 0x2Adr1/51635421f64d6de8cbb14dbf40a27a4e to your computer and use it in GitHub Desktop.
Repro sysroot issue
build --incompatible_strict_action_env
# Required to use the C/C++ toolchain managed by aspect_gcc_toolchain
build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build --incompatible_enable_cc_toolchain_resolution
# optional, but preferred for performance as per https://github.com/aspect-build/gcc-toolchain/issues/85
build --experimental_reuse_sandbox_directories
cc_binary(
name = "main",
srcs = [ "main.cpp" ],
)
#include <iostream>
#include <bits/types/struct___jmp_buf_tag.h>
int main()
{
std::cout << "hello\n";
return 0;
}
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# =============================================================================
# Dependencies for @aspect_gcc_toolchain
# @bazel_skylib
http_archive(
name = "bazel_skylib",
sha256 = "f24ab666394232f834f74d19e2ff142b0af17466ea0c69a3f4c276ee75f6efce",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz",
],
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
# @aspect_bazel_lib
http_archive(
name = "aspect_bazel_lib",
sha256 = "ef83252dea2ed8254c27e65124b756fc9476be2b73a7799b7a2a0935937fc573",
strip_prefix = "bazel-lib-1.24.2",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.24.2/bazel-lib-v1.24.2.tar.gz",
)
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
aspect_bazel_lib_dependencies()
# =============================================================================
git_repository(
name = "aspect_gcc_toolchain",
commit = "22862ac5637edc946a2d03f7fcc413b8c897b44f",
remote = "git@github.com:aspect-build/gcc-toolchain.git"
)
load("@aspect_gcc_toolchain//toolchain:defs.bzl", "ARCHS", "gcc_register_toolchain")
gcc_register_toolchain(
name = "gcc_toolchain_x86_64",
extra_cxxflags = [ "-std=c++17" ],
sysroot_variant = "x86_64",
target_arch = ARCHS.x86_64,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment