From 142b5769d2f770e4e226421bb5a9010a19e7a9f7 Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Fri, 6 Jun 2025 22:33:44 +0200 Subject: [PATCH 1/2] WIP --- .zed/settings.json | 4 ---- examples/.bazelrc | 8 ++++++++ platforms/BUILD.bazel | 36 +++++++++++------------------------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/.zed/settings.json b/.zed/settings.json index 955aea11..48325ec7 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -1,7 +1,3 @@ -// Folder-specific settings -// -// For a full list of overridable settings, and general information on folder-specific settings, -// see the documentation: https://zed.dev/docs/configuring-zed#settings-files { "languages": { "Zig": { diff --git a/examples/.bazelrc b/examples/.bazelrc index ff9d96f5..d4fe0ba7 100644 --- a/examples/.bazelrc +++ b/examples/.bazelrc @@ -18,6 +18,9 @@ common --experimental_remote_cache_eviction_retries=5 # Self explanatory common --enable_platform_specific_config +# Setup host platform +common --host_platform=@zml//platforms:host + # Ensure host tools are built optimized build --host_compilation_mode=opt @@ -120,3 +123,8 @@ common:release --compilation_mode=opt common:release --copt=-Ofast common:release --@rules_zig//zig/settings:mode=release_fast common:release --@rules_zig//zig/settings:copt=-fomit-frame-pointer + +build:lto --copt=-flto +build:lto --@rules_zig//zig/settings:copt=-flto +build:lto --@rules_zig//zig/settings:copt=-flld +build:lto --@rules_rust//rust/settings:extra_rustc_flag=-Clto=fat diff --git a/platforms/BUILD.bazel b/platforms/BUILD.bazel index 57756f40..97b4c906 100644 --- a/platforms/BUILD.bazel +++ b/platforms/BUILD.bazel @@ -1,44 +1,30 @@ -alias( +load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS") + +GLIBC = "@toolchains_llvm_bootstrapped//constraints/libc:gnu.2.34" +IS_LINUX = "@platforms//os:linux" in HOST_CONSTRAINTS + +platform( name = "host", - actual = select({ - "@platforms//os:linux": ":host_linux", - "//conditions:default": ":host_other", - }), -) - -platform( - name = "host_other", parents = ["@platforms//host"], - visibility = ["//visibility:public"], -) - - -platform( - name = "host_linux", - parents = ["@platforms//host"], - constraint_values = [ - "@toolchains_llvm_bootstrapped//constraints/libc:gnu.2.31", - ], + constraint_values = [GLIBC] if IS_LINUX else [], visibility = ["//visibility:public"], ) platform( name = "linux_amd64", constraint_values = [ - "@platforms//cpu:x86_64", "@platforms//os:linux", - "@toolchains_llvm_bootstrapped//constraints/libc:gnu.2.31", - ], + "@platforms//cpu:x86_64", + ] + [GLIBC] if IS_LINUX else [], visibility = ["//visibility:public"], ) platform( name = "linux_arm64", constraint_values = [ - "@platforms//cpu:aarch64", "@platforms//os:linux", - "@toolchains_llvm_bootstrapped//constraints/libc:gnu.2.31", - ], + "@platforms//cpu:aarch64", + ] + [GLIBC] if IS_LINUX else [], visibility = ["//visibility:public"], ) From b9f6e4ac220fd305548999e550314ef0e491540b Mon Sep 17 00:00:00 2001 From: Steeve Morin Date: Sun, 15 Jun 2025 15:49:55 +0000 Subject: [PATCH 2/2] WIP --- examples/.bazelrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/.bazelrc b/examples/.bazelrc index d4fe0ba7..8bbc5100 100644 --- a/examples/.bazelrc +++ b/examples/.bazelrc @@ -127,4 +127,8 @@ common:release --@rules_zig//zig/settings:copt=-fomit-frame-pointer build:lto --copt=-flto build:lto --@rules_zig//zig/settings:copt=-flto build:lto --@rules_zig//zig/settings:copt=-flld -build:lto --@rules_rust//rust/settings:extra_rustc_flag=-Clto=fat +build:lto --@rules_rust//rust/settings:lto=fat + +build:native --copt=-march=native +build:native --@rules_zig//zig/settings:copt=-mcpu=native +build:native --@rules_rust//rust/settings:extra_rustc_flag=-Ctarget-cpu=native