From 3bef8a7bdca305d3d7136519fbc33892d7da8657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Sun, 1 Dec 2024 15:20:46 +0100 Subject: [PATCH 01/25] specify aarch64-linux-gnu toolchain from Yggdrasil --- deps/ReactantExtra/BUILD | 93 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index ebae7923..5d95ad82 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -13,7 +13,7 @@ cc_toolchain_suite( "k8": ":ygg_x86_toolchain", "darwin": ":ygg_x86_toolchain", "darwin_arm64": ":ygg_x86_toolchain", - "linux_arm64": ":ygg_x86_toolchain", + "linux_arm64": ":ygg_aarch64_toolchain", }, ) cc_toolchain_suite( @@ -38,6 +38,19 @@ cc_toolchain( toolchain_identifier = "ygg_x86_toolchain", ) +cc_toolchain( + name = "ygg_aarch64_toolchain", + all_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 1, + toolchain_config = ":ygg_aarch64_toolchain_config", + toolchain_identifier = "ygg_aarch64_toolchain", +) + cc_toolchain_config( name = "ygg_x86_toolchain_config", abi_libc_version = "local", @@ -120,6 +133,84 @@ cc_toolchain_config( ], ) +cc_toolchain( + name = "ygg_aarch64_toolchain_config", + abi_libc_version = "local", + abi_version = "local", + builtin_sysroot = "/opt/aarch64-linux-gnu", + compile_flags = [ + ], + compiler = "gcc", + coverage_compile_flags = ["--coverage"], + coverage_link_flags = ["--coverage"], + cpu = "aarch64", + cxx_builtin_include_directories = [ + "/opt/x86_64-linux-musl/x86_64-linux-musl/include/c++/10.2.0", + "/opt/x86_64-linux-musl/x86_64-linux-musl/include/c++/10.2.0/x86_64-linux-musl", + "/opt/x86_64-linux-musl/x86_64-linux-musl/include/c++/10.2.0/backward", + "/opt/x86_64-linux-musl/x86_64-linux-musl/include", + "/opt/x86_64-linux-musl/bin/../include/x86_64-unknown-linux-musl/c++/v1", + "/opt/x86_64-linux-musl/bin/../include/c++/v1", + "/opt/x86_64-linux-musl/x86_64-linux-musl/sys-root/usr/include", + "/opt/x86_64-linux-musl/lib/clang/16/include", + "/opt/x86_64-linux-musl/lib/clang/17/include", + "/opt/x86_64-linux-musl/lib/clang/18/include", + ], + dbg_compile_flags = ["-g"], + host_system_name = "linux", + link_flags = [], + link_libs = [ + "-lstdc++", + "-lm", + ], + opt_compile_flags = [ + "-g0", + "-O2", + "-D_FORTIFY_SOURCE=1", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + "-stdlib=libstdc++", + ], + opt_link_flags = ["-Wl,--gc-sections"], + supports_start_end_lib = True, + target_libc = "", + tool_paths = { + "ar": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ar", + "as": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/as", + "c++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++", + "c++filt": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++filt", + "cc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cc", + "clang": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang", + "clang++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang++", + "cpp": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cpp", + "f77": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/f77", + "g++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/g++", + "gcc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gcc", + "gfortran": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gfortran", + "ld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld", + "ld.lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld.lld", + "libtool": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/libtool", + "lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/lld", + "nm": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/nm", + "objcopy": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/objcopy", + "patchelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/patchelf", + "ranlib": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ranlib", + "readelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/readelf", + "strip": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/strip", + }, + toolchain_identifier = "ygg_aarch64_toolchain", + unfiltered_compile_flags = [ + "-no-canonical-prefixes", + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + "-Wno-unused-command-line-argument", + "-Wno-gnu-offsetof-extensions", + ], +) + cc_toolchain( name = "beast_x86_toolchain", all_files = ":empty", From 6980c89a58925304bf1dc13c1e32be2504b09016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Sun, 1 Dec 2024 15:28:01 +0100 Subject: [PATCH 02/25] fix typo --- deps/ReactantExtra/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 5d95ad82..adcf5c59 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -133,7 +133,7 @@ cc_toolchain_config( ], ) -cc_toolchain( +cc_toolchain_config( name = "ygg_aarch64_toolchain_config", abi_libc_version = "local", abi_version = "local", From 5cf6615ce9110c7c034a4ed8a5135cde5df426d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Sun, 1 Dec 2024 15:32:23 +0100 Subject: [PATCH 03/25] add missing `target_system_name` value --- deps/ReactantExtra/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index adcf5c59..46bdd16f 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -175,6 +175,7 @@ cc_toolchain_config( opt_link_flags = ["-Wl,--gc-sections"], supports_start_end_lib = True, target_libc = "", + target_system_name = "aarch64-unknown-linux-gnu", tool_paths = { "ar": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ar", "as": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/as", From aa3fa24efb4133f4edd3229f7e68ccda6f6ddde6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Sun, 1 Dec 2024 15:36:42 +0100 Subject: [PATCH 04/25] add tool path to `llvm-cov` --- deps/ReactantExtra/BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 46bdd16f..c325db21 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -199,6 +199,8 @@ cc_toolchain_config( "ranlib": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ranlib", "readelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/readelf", "strip": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/strip", + # from host + "llvm-cov": "/opt/x86_64-linux-musl/bin/llvm-cov", }, toolchain_identifier = "ygg_aarch64_toolchain", unfiltered_compile_flags = [ From bb25e40b4165961809fee289f1e92843b4669a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 17:11:41 +0100 Subject: [PATCH 05/25] refactor toolchain --- deps/ReactantExtra/BUILD | 80 +++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index c325db21..e6948d2c 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -135,47 +135,22 @@ cc_toolchain_config( cc_toolchain_config( name = "ygg_aarch64_toolchain_config", + cpu = "aarch64", + compiler = "clang", + toolchain_identifier = "ygg_aarch64_toolchain", + target_system_name = "aarch64-unknown-linux-gnu", + target_libc = "", abi_libc_version = "local", abi_version = "local", - builtin_sysroot = "/opt/aarch64-linux-gnu", - compile_flags = [ - ], - compiler = "gcc", - coverage_compile_flags = ["--coverage"], - coverage_link_flags = ["--coverage"], - cpu = "aarch64", cxx_builtin_include_directories = [ - "/opt/x86_64-linux-musl/x86_64-linux-musl/include/c++/10.2.0", - "/opt/x86_64-linux-musl/x86_64-linux-musl/include/c++/10.2.0/x86_64-linux-musl", - "/opt/x86_64-linux-musl/x86_64-linux-musl/include/c++/10.2.0/backward", - "/opt/x86_64-linux-musl/x86_64-linux-musl/include", - "/opt/x86_64-linux-musl/bin/../include/x86_64-unknown-linux-musl/c++/v1", - "/opt/x86_64-linux-musl/bin/../include/c++/v1", - "/opt/x86_64-linux-musl/x86_64-linux-musl/sys-root/usr/include", - "/opt/x86_64-linux-musl/lib/clang/16/include", - "/opt/x86_64-linux-musl/lib/clang/17/include", - "/opt/x86_64-linux-musl/lib/clang/18/include", - ], - dbg_compile_flags = ["-g"], - host_system_name = "linux", - link_flags = [], - link_libs = [ - "-lstdc++", - "-lm", + "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", + "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", + "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include", + "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include", + "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0", + "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/aarch64-linux-gnu", + "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward" ], - opt_compile_flags = [ - "-g0", - "-O2", - "-D_FORTIFY_SOURCE=1", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - "-stdlib=libstdc++", - ], - opt_link_flags = ["-Wl,--gc-sections"], - supports_start_end_lib = True, - target_libc = "", - target_system_name = "aarch64-unknown-linux-gnu", tool_paths = { "ar": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ar", "as": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/as", @@ -201,8 +176,32 @@ cc_toolchain_config( "strip": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/strip", # from host "llvm-cov": "/opt/x86_64-linux-musl/bin/llvm-cov", + "llvm-profdata": "/opt/x86_64-linux-musl/bin/llvm-profdata", + "objdump": "/usr/bin/objdump", }, - toolchain_identifier = "ygg_aarch64_toolchain", + compile_flags = [ + "-fstack-protector", + "-Wall", + "-Wunused-but-set-parameter", + "-Wno-free-nonheap-object", + "-fno-omit-frame-pointer" + ], + opt_compile_flags = [ + "-g0", + "-O2", + "-D_FORTIFY_SOURCE=1", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + "-stdlib=libstdc++", + ], + dbg_compile_flags = ["-g"], + link_flags = [], + link_libs = [ + "-lstdc++", + "-lm", + ], + opt_link_flags = ["-Wl,--gc-sections"], unfiltered_compile_flags = [ "-no-canonical-prefixes", "-Wno-builtin-macro-redefined", @@ -212,6 +211,11 @@ cc_toolchain_config( "-Wno-unused-command-line-argument", "-Wno-gnu-offsetof-extensions", ], + builtin_sysroot = "/opt/aarch64-linux-gnu", + coverage_compile_flags = ["--coverage"], + coverage_link_flags = ["--coverage"], + host_system_name = "linux", + supports_start_end_lib = True, ) cc_toolchain( From f8a42769cf966a79db6c714e439a6ece7d369fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 17:18:56 +0100 Subject: [PATCH 06/25] rename toolchain identifier --- deps/ReactantExtra/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index e6948d2c..bc69c811 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -137,7 +137,7 @@ cc_toolchain_config( name = "ygg_aarch64_toolchain_config", cpu = "aarch64", compiler = "clang", - toolchain_identifier = "ygg_aarch64_toolchain", + toolchain_identifier = "ygg_aarch64", target_system_name = "aarch64-unknown-linux-gnu", target_libc = "", abi_libc_version = "local", From 86a587dedebf9f458f6abf291414b8f8063491fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 17:31:44 +0100 Subject: [PATCH 07/25] try fix `cc_toolchain_suite` --- deps/ReactantExtra/BUILD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index bc69c811..560432d9 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -13,9 +13,10 @@ cc_toolchain_suite( "k8": ":ygg_x86_toolchain", "darwin": ":ygg_x86_toolchain", "darwin_arm64": ":ygg_x86_toolchain", - "linux_arm64": ":ygg_aarch64_toolchain", + "aarch64": ":ygg_aarch64_toolchain", }, ) + cc_toolchain_suite( name = "beast_toolchain_suite", toolchains = { From 33cb5a6220b41d8241e3da3104bc8521d5d4949c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 17:33:22 +0100 Subject: [PATCH 08/25] register yggdrasil's aarch64 toolchain --- deps/ReactantExtra/WORKSPACE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deps/ReactantExtra/WORKSPACE b/deps/ReactantExtra/WORKSPACE index 174cc671..23587acb 100644 --- a/deps/ReactantExtra/WORKSPACE +++ b/deps/ReactantExtra/WORKSPACE @@ -229,3 +229,5 @@ load( ) nccl_configure(name = "local_config_nccl") + +register_toolchains("//:ygg_aarch64_toolchain") From 53dfafe174f5d88b72fb24a266b55b73a484b38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 17:43:26 +0100 Subject: [PATCH 09/25] try fix the `DeclaredToolchainInfo` provider by wrapping the toolchain in a `toolchain` --- deps/ReactantExtra/BUILD | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 560432d9..9a244165 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -39,6 +39,13 @@ cc_toolchain( toolchain_identifier = "ygg_x86_toolchain", ) +toolchain( + name = "ygg_aarch64_toolchain_wrapper", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", + target_compatible_with = [], + toolchain = ":ygg_aarch64_toolchain", +) + cc_toolchain( name = "ygg_aarch64_toolchain", all_files = ":empty", From 76b737f9b501bcfa3e5a0fd7b917c72c5da7dc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 22:55:27 +0100 Subject: [PATCH 10/25] some small refactors --- deps/ReactantExtra/BUILD | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 9a244165..ba40fd83 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -40,14 +40,13 @@ cc_toolchain( ) toolchain( - name = "ygg_aarch64_toolchain_wrapper", + name = "ygg_aarch64_toolchain", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", - target_compatible_with = [], - toolchain = ":ygg_aarch64_toolchain", + toolchain = ":ygg_aarch64_cc_toolchain", ) cc_toolchain( - name = "ygg_aarch64_toolchain", + name = "ygg_aarch64_cc_toolchain", all_files = ":empty", compiler_files = ":empty", dwp_files = ":empty", @@ -55,8 +54,8 @@ cc_toolchain( objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - toolchain_config = ":ygg_aarch64_toolchain_config", - toolchain_identifier = "ygg_aarch64_toolchain", + toolchain_config = ":ygg_aarch64_cc_toolchain_config", + toolchain_identifier = "ygg_aarch64_cc_toolchain", ) cc_toolchain_config( @@ -142,7 +141,7 @@ cc_toolchain_config( ) cc_toolchain_config( - name = "ygg_aarch64_toolchain_config", + name = "ygg_aarch64_cc_toolchain_config", cpu = "aarch64", compiler = "clang", toolchain_identifier = "ygg_aarch64", From cc1596e08dd446bbb0193c5c020427a3e604a133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 23:23:50 +0100 Subject: [PATCH 11/25] stop using new `toolchain` and `register_toolchains` --- deps/ReactantExtra/BUILD | 14 ++++---------- deps/ReactantExtra/WORKSPACE | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index ba40fd83..560432d9 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -39,14 +39,8 @@ cc_toolchain( toolchain_identifier = "ygg_x86_toolchain", ) -toolchain( - name = "ygg_aarch64_toolchain", - toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", - toolchain = ":ygg_aarch64_cc_toolchain", -) - cc_toolchain( - name = "ygg_aarch64_cc_toolchain", + name = "ygg_aarch64_toolchain", all_files = ":empty", compiler_files = ":empty", dwp_files = ":empty", @@ -54,8 +48,8 @@ cc_toolchain( objcopy_files = ":empty", strip_files = ":empty", supports_param_files = 1, - toolchain_config = ":ygg_aarch64_cc_toolchain_config", - toolchain_identifier = "ygg_aarch64_cc_toolchain", + toolchain_config = ":ygg_aarch64_toolchain_config", + toolchain_identifier = "ygg_aarch64_toolchain", ) cc_toolchain_config( @@ -141,7 +135,7 @@ cc_toolchain_config( ) cc_toolchain_config( - name = "ygg_aarch64_cc_toolchain_config", + name = "ygg_aarch64_toolchain_config", cpu = "aarch64", compiler = "clang", toolchain_identifier = "ygg_aarch64", diff --git a/deps/ReactantExtra/WORKSPACE b/deps/ReactantExtra/WORKSPACE index 23587acb..174cc671 100644 --- a/deps/ReactantExtra/WORKSPACE +++ b/deps/ReactantExtra/WORKSPACE @@ -229,5 +229,3 @@ load( ) nccl_configure(name = "local_config_nccl") - -register_toolchains("//:ygg_aarch64_toolchain") From 4aa64ffc4c5db0756f3f4c5fae02dc806a8463f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 23:35:44 +0100 Subject: [PATCH 12/25] try aarch64 build without `-stdlib=libstdc++` flag as it's selecting GCC compiler --- deps/ReactantExtra/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 560432d9..29cbcc70 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -194,7 +194,7 @@ cc_toolchain_config( "-DNDEBUG", "-ffunction-sections", "-fdata-sections", - "-stdlib=libstdc++", + # "-stdlib=libstdc++", ], dbg_compile_flags = ["-g"], link_flags = [], From 30e205cabb890c3dadd273f79f5811ae70aeaed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 2 Dec 2024 23:57:36 +0100 Subject: [PATCH 13/25] add header path --- deps/ReactantExtra/BUILD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 29cbcc70..936e93ce 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -150,7 +150,8 @@ cc_toolchain_config( "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include", "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0", "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/aarch64-linux-gnu", - "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward" + "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward", + "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel" ], tool_paths = { "ar": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ar", From 65e34212efa185341e625ee7b7adfcb5787c881a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 09:45:12 +0100 Subject: [PATCH 14/25] try fix header inclusion --- deps/ReactantExtra/BUILD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 936e93ce..7c3eb39f 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -186,7 +186,8 @@ cc_toolchain_config( "-Wall", "-Wunused-but-set-parameter", "-Wno-free-nonheap-object", - "-fno-omit-frame-pointer" + "-fno-omit-frame-pointer", + "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel", ], opt_compile_flags = [ "-g0", From 636aab70aeec2e9e512004e5ee53d9aba5fe4970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 11:51:26 +0100 Subject: [PATCH 15/25] manually add `-I` flags --- deps/ReactantExtra/BUILD | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 7c3eb39f..569fe0c5 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -187,6 +187,14 @@ cc_toolchain_config( "-Wunused-but-set-parameter", "-Wno-free-nonheap-object", "-fno-omit-frame-pointer", + # TODO cxx_builtin_include_directories doesn't seem to be working, so we add the INCLUDE_PATHs manually + "-I/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", + "-I/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", + "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include", + "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include", + "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0", + "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/aarch64-linux-gnu", + "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward", "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel", ], opt_compile_flags = [ From c9901e46e21ddf49f1b0578d41838be8fed6b3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 12:01:27 +0100 Subject: [PATCH 16/25] try adding sysroot --- deps/ReactantExtra/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 569fe0c5..0c6aa43a 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -143,6 +143,7 @@ cc_toolchain_config( target_libc = "", abi_libc_version = "local", abi_version = "local", + builtin_sysroot = "/opt/aarch64-linux-gnu/aarch64-linux-gnu", cxx_builtin_include_directories = [ "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", From 67f67db5ae1da1f9ec77e19f30e55fdb560f262e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 12:07:38 +0100 Subject: [PATCH 17/25] fix duplicated sys-root --- deps/ReactantExtra/BUILD | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 0c6aa43a..adfecfce 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -143,7 +143,6 @@ cc_toolchain_config( target_libc = "", abi_libc_version = "local", abi_version = "local", - builtin_sysroot = "/opt/aarch64-linux-gnu/aarch64-linux-gnu", cxx_builtin_include_directories = [ "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", @@ -223,7 +222,7 @@ cc_toolchain_config( "-Wno-unused-command-line-argument", "-Wno-gnu-offsetof-extensions", ], - builtin_sysroot = "/opt/aarch64-linux-gnu", + builtin_sysroot = "/opt/aarch64-linux-gnu/aarch64-linux-gnu", coverage_compile_flags = ["--coverage"], coverage_link_flags = ["--coverage"], host_system_name = "linux", From 4e1cadb1e753ff253d89c272339616708ec7e8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 12:58:10 +0100 Subject: [PATCH 18/25] fix sysroot --- deps/ReactantExtra/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index adfecfce..a2d31798 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -222,7 +222,7 @@ cc_toolchain_config( "-Wno-unused-command-line-argument", "-Wno-gnu-offsetof-extensions", ], - builtin_sysroot = "/opt/aarch64-linux-gnu/aarch64-linux-gnu", + builtin_sysroot = "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/", coverage_compile_flags = ["--coverage"], coverage_link_flags = ["--coverage"], host_system_name = "linux", From 94d2338ff017a7860fcb484dfaa63cc0c0d6191d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 13:12:26 +0100 Subject: [PATCH 19/25] refactor `-I` flags to `-isystem` --- deps/ReactantExtra/BUILD | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index a2d31798..ee3e3672 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -188,14 +188,14 @@ cc_toolchain_config( "-Wno-free-nonheap-object", "-fno-omit-frame-pointer", # TODO cxx_builtin_include_directories doesn't seem to be working, so we add the INCLUDE_PATHs manually - "-I/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", - "-I/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", - "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include", - "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include", - "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0", - "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/aarch64-linux-gnu", - "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward", - "-I/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel", + "-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", + "-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", + "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include", + "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include", + "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0", + "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/aarch64-linux-gnu", + "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward", + "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel", ], opt_compile_flags = [ "-g0", From ebaa8cf006f0823a62d34f5d27f71ac4de991e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 14:38:50 +0100 Subject: [PATCH 20/25] try make the toolchain clang/gcc agnostic --- deps/ReactantExtra/BUILD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index ee3e3672..48d0908c 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -134,10 +134,11 @@ cc_toolchain_config( ], ) +# TODO distinguish between clang and gcc toolchains cc_toolchain_config( name = "ygg_aarch64_toolchain_config", cpu = "aarch64", - compiler = "clang", + compiler = "compiler", toolchain_identifier = "ygg_aarch64", target_system_name = "aarch64-unknown-linux-gnu", target_libc = "", From 1ae4de2fb9feb45bbc314d2bc383d2816cf8ea4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 15:48:38 +0100 Subject: [PATCH 21/25] disable `supports_start_end_lib` on Yggdrasil aarch64 toolchain --- deps/ReactantExtra/BUILD | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 48d0908c..76b88b65 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -227,7 +227,8 @@ cc_toolchain_config( coverage_compile_flags = ["--coverage"], coverage_link_flags = ["--coverage"], host_system_name = "linux", - supports_start_end_lib = True, + # TODO gcc doesn't support it, only put it on clang (maybe even only for clang on aarch64-darwin?) + supports_start_end_lib = False, ) cc_toolchain( From fc9434a759c1ae15bdc4482911ace816ecf3605a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 19:03:21 +0100 Subject: [PATCH 22/25] try using glob expansion on `tool_paths` --- deps/ReactantExtra/BUILD | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 76b88b65..07cd48b4 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -155,28 +155,28 @@ cc_toolchain_config( "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel" ], tool_paths = { - "ar": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ar", - "as": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/as", - "c++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++", - "c++filt": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++filt", - "cc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cc", - "clang": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang", - "clang++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang++", - "cpp": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cpp", - "f77": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/f77", - "g++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/g++", - "gcc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gcc", - "gfortran": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gfortran", - "ld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld", - "ld.lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld.lld", - "libtool": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/libtool", - "lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/lld", - "nm": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/nm", - "objcopy": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/objcopy", - "patchelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/patchelf", - "ranlib": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ranlib", - "readelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/readelf", - "strip": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/strip", + "ar": "/opt/bin/aarch64-linux-gnu-*/ar", + "as": "/opt/bin/aarch64-linux-gnu-*/as", + "c++": "/opt/bin/aarch64-linux-gnu-*/c++", + "c++filt": "/opt/bin/aarch64-linux-gnu-*/c++filt", + "cc": "/opt/bin/aarch64-linux-gnu-*/cc", + "clang": "/opt/bin/aarch64-linux-gnu-*/clang", + "clang++": "/opt/bin/aarch64-linux-gnu-*/clang++", + "cpp": "/opt/bin/aarch64-linux-gnu-*/cpp", + "f77": "/opt/bin/aarch64-linux-gnu-*/f77", + "g++": "/opt/bin/aarch64-linux-gnu-*/g++", + "gcc": "/opt/bin/aarch64-linux-gnu-*/gcc", + "gfortran": "/opt/bin/aarch64-linux-gnu-*/gfortran", + "ld": "/opt/bin/aarch64-linux-gnu-*/ld", + "ld.lld": "/opt/bin/aarch64-linux-gnu-*/ld.lld", + "libtool": "/opt/bin/aarch64-linux-gnu-*/libtool", + "lld": "/opt/bin/aarch64-linux-gnu-*/lld", + "nm": "/opt/bin/aarch64-linux-gnu-*/nm", + "objcopy": "/opt/bin/aarch64-linux-gnu-*/objcopy", + "patchelf": "/opt/bin/aarch64-linux-gnu-*/patchelf", + "ranlib": "/opt/bin/aarch64-linux-gnu-*/ranlib", + "readelf": "/opt/bin/aarch64-linux-gnu-*/readelf", + "strip": "/opt/bin/aarch64-linux-gnu-*/strip", # from host "llvm-cov": "/opt/x86_64-linux-musl/bin/llvm-cov", "llvm-profdata": "/opt/x86_64-linux-musl/bin/llvm-profdata", From c419aea2f8991e66fd4978d8a684440bcbb79a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 3 Dec 2024 22:02:00 +0100 Subject: [PATCH 23/25] change path of `tool_paths` again --- deps/ReactantExtra/BUILD | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 07cd48b4..76b88b65 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -155,28 +155,28 @@ cc_toolchain_config( "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel" ], tool_paths = { - "ar": "/opt/bin/aarch64-linux-gnu-*/ar", - "as": "/opt/bin/aarch64-linux-gnu-*/as", - "c++": "/opt/bin/aarch64-linux-gnu-*/c++", - "c++filt": "/opt/bin/aarch64-linux-gnu-*/c++filt", - "cc": "/opt/bin/aarch64-linux-gnu-*/cc", - "clang": "/opt/bin/aarch64-linux-gnu-*/clang", - "clang++": "/opt/bin/aarch64-linux-gnu-*/clang++", - "cpp": "/opt/bin/aarch64-linux-gnu-*/cpp", - "f77": "/opt/bin/aarch64-linux-gnu-*/f77", - "g++": "/opt/bin/aarch64-linux-gnu-*/g++", - "gcc": "/opt/bin/aarch64-linux-gnu-*/gcc", - "gfortran": "/opt/bin/aarch64-linux-gnu-*/gfortran", - "ld": "/opt/bin/aarch64-linux-gnu-*/ld", - "ld.lld": "/opt/bin/aarch64-linux-gnu-*/ld.lld", - "libtool": "/opt/bin/aarch64-linux-gnu-*/libtool", - "lld": "/opt/bin/aarch64-linux-gnu-*/lld", - "nm": "/opt/bin/aarch64-linux-gnu-*/nm", - "objcopy": "/opt/bin/aarch64-linux-gnu-*/objcopy", - "patchelf": "/opt/bin/aarch64-linux-gnu-*/patchelf", - "ranlib": "/opt/bin/aarch64-linux-gnu-*/ranlib", - "readelf": "/opt/bin/aarch64-linux-gnu-*/readelf", - "strip": "/opt/bin/aarch64-linux-gnu-*/strip", + "ar": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ar", + "as": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/as", + "c++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++", + "c++filt": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++filt", + "cc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cc", + "clang": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang", + "clang++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang++", + "cpp": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cpp", + "f77": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/f77", + "g++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/g++", + "gcc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gcc", + "gfortran": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gfortran", + "ld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld", + "ld.lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld.lld", + "libtool": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/libtool", + "lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/lld", + "nm": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/nm", + "objcopy": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/objcopy", + "patchelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/patchelf", + "ranlib": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ranlib", + "readelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/readelf", + "strip": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/strip", # from host "llvm-cov": "/opt/x86_64-linux-musl/bin/llvm-cov", "llvm-profdata": "/opt/x86_64-linux-musl/bin/llvm-profdata", From c8432e595ab187b6c14b50fceee8210648005ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Wed, 4 Dec 2024 18:45:17 +0100 Subject: [PATCH 24/25] refactor toolchain to work with substitution in Yggdrasil --- deps/ReactantExtra/BUILD | 107 ++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 76b88b65..441e43b8 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -39,19 +39,6 @@ cc_toolchain( toolchain_identifier = "ygg_x86_toolchain", ) -cc_toolchain( - name = "ygg_aarch64_toolchain", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 1, - toolchain_config = ":ygg_aarch64_toolchain_config", - toolchain_identifier = "ygg_aarch64_toolchain", -) - cc_toolchain_config( name = "ygg_x86_toolchain_config", abi_libc_version = "local", @@ -134,7 +121,21 @@ cc_toolchain_config( ], ) -# TODO distinguish between clang and gcc toolchains +# TODO change it to more generic yggdrasil toolchain once we have it +cc_toolchain( + name = "ygg_aarch64_toolchain", + all_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 1, + toolchain_config = ":ygg_aarch64_toolchain_config", + toolchain_identifier = "ygg_toolchain", +) + +# TODO distinguish between clang and gcc toolchains? cc_toolchain_config( name = "ygg_aarch64_toolchain_config", cpu = "aarch64", @@ -145,38 +146,38 @@ cc_toolchain_config( abi_libc_version = "local", abi_version = "local", cxx_builtin_include_directories = [ - "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", - "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", - "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include", - "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include", - "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0", - "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/aarch64-linux-gnu", - "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward", - "/opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel" + "/opt/BB_TARGET/lib/gcc/BB_TARGET/10.2.0/include", + "/opt/BB_TARGET/lib/gcc/BB_TARGET/10.2.0/include-fixed", + "/opt/BB_TARGET/BB_TARGET/include", + "/opt/BB_TARGET/BB_TARGET/sys-root/usr/include", + "/opt/BB_TARGET/BB_TARGET/include/c++/10.2.0", + "/opt/BB_TARGET/BB_TARGET/include/c++/10.2.0/BB_TARGET", + "/opt/BB_TARGET/BB_TARGET/include/c++/10.2.0/backward", + "/opt/BB_TARGET/BB_TARGET/include/c++/10.2.0/parallel" ], tool_paths = { - "ar": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ar", - "as": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/as", - "c++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++", - "c++filt": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/c++filt", - "cc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cc", - "clang": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang", - "clang++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/clang++", - "cpp": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/cpp", - "f77": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/f77", - "g++": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/g++", - "gcc": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gcc", - "gfortran": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/gfortran", - "ld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld", - "ld.lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ld.lld", - "libtool": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/libtool", - "lld": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/lld", - "nm": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/nm", - "objcopy": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/objcopy", - "patchelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/patchelf", - "ranlib": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/ranlib", - "readelf": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/readelf", - "strip": "/opt/bin/aarch64-linux-gnu-libgfortran5-cxx11-gpu+none-mode+opt/strip", + "ar": "/opt/bin/BB_FULL_TARGET/ar", + "as": "/opt/bin/BB_FULL_TARGET/as", + "c++": "/opt/bin/BB_FULL_TARGET/c++", + "c++filt": "/opt/bin/BB_FULL_TARGET/c++filt", + "cc": "/opt/bin/BB_FULL_TARGET/cc", + "clang": "/opt/bin/BB_FULL_TARGET/clang", + "clang++": "/opt/bin/BB_FULL_TARGET/clang++", + "cpp": "/opt/bin/BB_FULL_TARGET/cpp", + "f77": "/opt/bin/BB_FULL_TARGET/f77", + "g++": "/opt/bin/BB_FULL_TARGET/g++", + "gcc": "/opt/bin/BB_FULL_TARGET/gcc", + "gfortran": "/opt/bin/BB_FULL_TARGET/gfortran", + "ld": "/opt/bin/BB_FULL_TARGET/ld", + "ld.lld": "/opt/bin/BB_FULL_TARGET/ld.lld", + "libtool": "/opt/bin/BB_FULL_TARGET/libtool", + "lld": "/opt/bin/BB_FULL_TARGET/lld", + "nm": "/opt/bin/BB_FULL_TARGET/nm", + "objcopy": "/opt/bin/BB_FULL_TARGET/objcopy", + "patchelf": "/opt/bin/BB_FULL_TARGET/patchelf", + "ranlib": "/opt/bin/BB_FULL_TARGET/ranlib", + "readelf": "/opt/bin/BB_FULL_TARGET/readelf", + "strip": "/opt/bin/BB_FULL_TARGET/strip", # from host "llvm-cov": "/opt/x86_64-linux-musl/bin/llvm-cov", "llvm-profdata": "/opt/x86_64-linux-musl/bin/llvm-profdata", @@ -189,14 +190,14 @@ cc_toolchain_config( "-Wno-free-nonheap-object", "-fno-omit-frame-pointer", # TODO cxx_builtin_include_directories doesn't seem to be working, so we add the INCLUDE_PATHs manually - "-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include", - "-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/10.2.0/include-fixed", - "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include", - "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include", - "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0", - "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/aarch64-linux-gnu", - "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/backward", - "-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/10.2.0/parallel", + "-isystem /opt/BB_TARGET/lib/gcc/BB_TARGET/10.2.0/include", + "-isystem /opt/BB_TARGET/lib/gcc/BB_TARGET/10.2.0/include-fixed", + "-isystem /opt/BB_TARGET/BB_TARGET/include", + "-isystem /opt/BB_TARGET/BB_TARGET/sys-root/usr/include", + "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/10.2.0", + "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/10.2.0/BB_TARGET", + "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/10.2.0/backward", + "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/10.2.0/parallel", ], opt_compile_flags = [ "-g0", @@ -223,7 +224,7 @@ cc_toolchain_config( "-Wno-unused-command-line-argument", "-Wno-gnu-offsetof-extensions", ], - builtin_sysroot = "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/", + builtin_sysroot = "/opt/BB_TARGET/BB_TARGET/sys-root/", coverage_compile_flags = ["--coverage"], coverage_link_flags = ["--coverage"], host_system_name = "linux", From 7c9019852c4cfa67509f71e904c0704e2bbfa464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Wed, 4 Dec 2024 18:45:46 +0100 Subject: [PATCH 25/25] leave some extra code for future implementation of Yggdrasil's toolchain --- deps/ReactantExtra/BUILD | 1 + deps/ReactantExtra/toolchain/yggdrasil.bzl | 117 +++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 deps/ReactantExtra/toolchain/yggdrasil.bzl diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 441e43b8..75ae01a1 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -1,5 +1,6 @@ load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") load("@xla//tools/toolchains/cross_compile/cc:cc_toolchain_config.bzl", "cc_toolchain_config") +# load("//toolchain:yggdrasil.bzl", "ygg_cc_toolchain") licenses(["notice"]) package( diff --git a/deps/ReactantExtra/toolchain/yggdrasil.bzl b/deps/ReactantExtra/toolchain/yggdrasil.bzl new file mode 100644 index 00000000..5ead0330 --- /dev/null +++ b/deps/ReactantExtra/toolchain/yggdrasil.bzl @@ -0,0 +1,117 @@ +load("@rules_cc//cc:defs.bzl", "cc_toolchain") +load("@xla//tools/toolchains/cross_compile/cc:cc_toolchain_config.bzl", "cc_toolchain_config") + +# name = "ygg_aarch64_toolchain_config" +# cpu = "aarch64" +# toolchain_identifier = "ygg_aarch64" +# target_system_name = "aarch64-unknown-linux-gnu" +def ygg_cc_toolchain(cpu, toolchain_identifier, target_system_name, bb_target, bb_full_target, supports_start_end_lib = False): + cc_toolchain( + name = "ygg_target_toolchain", + all_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 1, + toolchain_config = ":ygg_target_toolchain_config", + toolchain_identifier = "ygg_toolchain", + ) + + # TODO distinguish between clang and gcc toolchains? + cc_toolchain_config( + name = "ygg_target_toolchain_config", + cpu = cpu, + compiler = "compiler", + toolchain_identifier = toolchain_identifier, + target_system_name = target_system_name, + target_libc = "", + abi_libc_version = "local", + abi_version = "local", + cxx_builtin_include_directories = [ + f"/opt/{bb_target}/lib/gcc/{bb_target}/10.2.0/include", + f"/opt/{bb_target}/lib/gcc/{bb_target}/10.2.0/include-fixed", + f"/opt/{bb_target}/{bb_target}/include", + f"/opt/{bb_target}/{bb_target}/sys-root/usr/include", + f"/opt/{bb_target}/{bb_target}/include/c++/10.2.0", + f"/opt/{bb_target}/{bb_target}/include/c++/10.2.0/{bb_target}", + f"/opt/{bb_target}/{bb_target}/include/c++/10.2.0/backward", + f"/opt/{bb_target}/{bb_target}/include/c++/10.2.0/parallel" + ], + tool_paths = { + "ar": f"/opt/bin/{bb_full_target}/ar", + "as": f"/opt/bin/{bb_full_target}/as", + "c++": f"/opt/bin/{bb_full_target}/c++", + "c++filt": f"/opt/bin/{bb_full_target}/c++filt", + "cc": f"/opt/bin/{bb_full_target}/cc", + "clang": f"/opt/bin/{bb_full_target}/clang", + "clang++": f"/opt/bin/{bb_full_target}/clang++", + "cpp": f"/opt/bin/{bb_full_target}/cpp", + "f77": f"/opt/bin/{bb_full_target}/f77", + "g++": f"/opt/bin/{bb_full_target}/g++", + "gcc": f"/opt/bin/{bb_full_target}/gcc", + "gfortran": f"/opt/bin/{bb_full_target}/gfortran", + "ld": f"/opt/bin/{bb_full_target}/ld", + "ld.lld": f"/opt/bin/{bb_full_target}/ld.lld", + "libtool": f"/opt/bin/{bb_full_target}/libtool", + "lld": f"/opt/bin/{bb_full_target}/lld", + "nm": f"/opt/bin/{bb_full_target}/nm", + "objcopy": f"/opt/bin/{bb_full_target}/objcopy", + "patchelf": f"/opt/bin/{bb_full_target}/patchelf", + "ranlib": f"/opt/bin/{bb_full_target}/ranlib", + "readelf": f"/opt/bin/{bb_full_target}/readelf", + "strip": f"/opt/bin/{bb_full_target}/strip", + # from host + "llvm-cov": "/opt/x86_64-linux-musl/bin/llvm-cov", + "llvm-profdata": "/opt/x86_64-linux-musl/bin/llvm-profdata", + "objdump": "/usr/bin/objdump", + }, + compile_flags = [ + "-fstack-protector", + "-Wall", + "-Wunused-but-set-parameter", + "-Wno-free-nonheap-object", + "-fno-omit-frame-pointer", + # TODO cxx_builtin_include_directories doesn't seem to be working, so we add the INCLUDE_PATHs manually + f"-isystem /opt/{bb_target}/lib/gcc/{bb_target}/10.2.0/include", + f"-isystem /opt/{bb_target}/lib/gcc/{bb_target}/10.2.0/include-fixed", + f"-isystem /opt/{bb_target}/{bb_target}/include", + f"-isystem /opt/{bb_target}/{bb_target}/sys-root/usr/include", + f"-isystem /opt/{bb_target}/{bb_target}/include/c++/10.2.0", + f"-isystem /opt/{bb_target}/{bb_target}/include/c++/10.2.0/{bb_target}", + f"-isystem /opt/{bb_target}/{bb_target}/include/c++/10.2.0/backward", + f"-isystem /opt/{bb_target}/{bb_target}/include/c++/10.2.0/parallel", + ], + opt_compile_flags = [ + "-g0", + "-O2", + "-D_FORTIFY_SOURCE=1", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + # "-stdlib=libstdc++", + ], + dbg_compile_flags = ["-g"], + link_flags = [], + link_libs = [ + "-lstdc++", + "-lm", + ], + opt_link_flags = ["-Wl,--gc-sections"], + unfiltered_compile_flags = [ + "-no-canonical-prefixes", + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + "-Wno-unused-command-line-argument", + "-Wno-gnu-offsetof-extensions", + ], + builtin_sysroot = f"/opt/{bb_target}/{bb_target}/sys-root/", + coverage_compile_flags = ["--coverage"], + coverage_link_flags = ["--coverage"], + host_system_name = "linux", + # TODO gcc doesn't support it, only put it on clang (maybe even only for clang on aarch64-darwin?) + supports_start_end_lib = supports_start_end_lib, + )