From 9375f57693db15ee355725a76d69673a0cfbf2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= <15837247+mofeing@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:56:14 +0100 Subject: [PATCH] Modularize Bazel build (#421) * organize platforms and toolchains * hardcode libcxxwrap_julia path * format code * remove outdated hardcoded symbolic links * add third party bazel wrapper to libcxxwrap_julia * readd platforms * some small fixes * first step on moving externals to modular organization * refactor libcxxwrap_julia on top of `cc_import` * use modular workspaces * add `libcxxwrap_julia` as dependency * hardcode julia dep * export `reactant_*` functions * downgrade libcxxwrap_julia to v0.13.3 * fix major version when linking to libcxxwrap_julia * remove legacy export * move `API.cpp` to new `src/` folder to start modularizing code * export `register_julia_module` from libcxxwrap_julia * fix symbol visibility * clean code remove libcxxwrap and julia deps * format code * import hedron compile commands from Enzyme-JAX * move deps commits to `workspace.bzl` --- deps/ReactantExtra/BUILD | 371 +++++++++--------- deps/ReactantExtra/WORKSPACE | 183 +++------ deps/ReactantExtra/{ => src}/API.cpp | 0 deps/ReactantExtra/third_party/BUILD | 1 + .../third_party/build_bazel_rules_apple/BUILD | 0 .../build_bazel_rules_apple/workspace.bzl | 10 + deps/ReactantExtra/third_party/enzyme/BUILD | 0 .../third_party/enzyme/workspace.bzl | 12 + .../ReactantExtra/third_party/enzyme_ad/BUILD | 0 .../third_party/enzyme_ad/workspace.bzl | 12 + deps/ReactantExtra/third_party/jax/BUILD | 0 .../third_party/jax/workspace.bzl | 14 + deps/ReactantExtra/third_party/nsync/BUILD | 0 .../third_party/nsync/workspace.bzl | 12 + deps/ReactantExtra/third_party/rules_cc/BUILD | 0 .../third_party/rules_cc/workspace.bzl | 14 + .../third_party/rules_python/BUILD | 0 .../third_party/rules_python/workspace.bzl | 12 + deps/ReactantExtra/third_party/upb/BUILD | 0 .../third_party/upb/workspace.bzl | 16 + deps/ReactantExtra/third_party/xla/BUILD | 0 .../third_party/xla/workspace.bzl | 26 ++ deps/ReactantExtra/tools/platforms.bzl | 31 ++ .../toolchains/yggdrasil/BUILD} | 0 deps/ReactantExtra/workspace.bzl | 14 + deps/clang | 2 - deps/clang++ | 2 - deps/gcc | 3 - 28 files changed, 397 insertions(+), 338 deletions(-) rename deps/ReactantExtra/{ => src}/API.cpp (100%) create mode 100644 deps/ReactantExtra/third_party/BUILD create mode 100644 deps/ReactantExtra/third_party/build_bazel_rules_apple/BUILD create mode 100644 deps/ReactantExtra/third_party/build_bazel_rules_apple/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/enzyme/BUILD create mode 100644 deps/ReactantExtra/third_party/enzyme/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/enzyme_ad/BUILD create mode 100644 deps/ReactantExtra/third_party/enzyme_ad/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/jax/BUILD create mode 100644 deps/ReactantExtra/third_party/jax/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/nsync/BUILD create mode 100644 deps/ReactantExtra/third_party/nsync/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/rules_cc/BUILD create mode 100644 deps/ReactantExtra/third_party/rules_cc/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/rules_python/BUILD create mode 100644 deps/ReactantExtra/third_party/rules_python/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/upb/BUILD create mode 100644 deps/ReactantExtra/third_party/upb/workspace.bzl create mode 100644 deps/ReactantExtra/third_party/xla/BUILD create mode 100644 deps/ReactantExtra/third_party/xla/workspace.bzl create mode 100644 deps/ReactantExtra/tools/platforms.bzl rename deps/ReactantExtra/{toolchain/yggdrasil.bzl => tools/toolchains/yggdrasil/BUILD} (100%) create mode 100644 deps/ReactantExtra/workspace.bzl delete mode 100755 deps/clang delete mode 100755 deps/clang++ delete mode 100755 deps/gcc diff --git a/deps/ReactantExtra/BUILD b/deps/ReactantExtra/BUILD index 781548809..92074fb10 100644 --- a/deps/ReactantExtra/BUILD +++ b/deps/ReactantExtra/BUILD @@ -1,10 +1,10 @@ -load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") +load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library") +load("@local_config_rocm//rocm:build_defs.bzl", "if_rocm") load("@xla//tools/toolchains/cross_compile/cc:cc_toolchain_config.bzl", "cc_toolchain_config") + # load("//toolchain:yggdrasil.bzl", "ygg_cc_toolchain") licenses(["notice"]) -load("@local_config_rocm//rocm:build_defs.bzl", "if_rocm") - package( default_applicable_licenses = [], default_visibility = ["//:__subpackages__"], @@ -92,7 +92,7 @@ cc_toolchain_config( "-DNDEBUG", "-ffunction-sections", "-fdata-sections", - "-stdlib=libstdc++" + "-stdlib=libstdc++", ], opt_link_flags = ["-Wl,--gc-sections"], supports_start_end_lib = True, @@ -102,10 +102,10 @@ cc_toolchain_config( #"gcc": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-gcc", #"cpp": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-g++", #"ld": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-ld", - "gcc": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-clang", - "g++": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-clang++", - "cpp": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-clang++", - "ld": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-ld.lld", + "gcc": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-clang", + "g++": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-clang++", + "cpp": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-clang++", + "ld": "/opt/bin/x86_64-linux-musl-cxx11/x86_64-linux-musl-ld.lld", #"gcc": "/opt/x86_64-linux-musl/bin/clang", #"ld": "/opt/x86_64-linux-musl/bin/ld.lld", #"cpp": "/opt/x86_64-linux-musl/bin/clang++", @@ -144,13 +144,29 @@ cc_toolchain( # TODO distinguish between clang and gcc toolchains? cc_toolchain_config( name = "ygg_aarch64_toolchain_config", - cpu = "aarch64", - compiler = "compiler", - toolchain_identifier = "ygg_aarch64", - target_system_name = "aarch64-unknown-linux-gnu", - target_libc = "", abi_libc_version = "local", abi_version = "local", + builtin_sysroot = "/opt/BB_TARGET/BB_TARGET/sys-root/", + 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 + "-isystem /opt/BB_TARGET/lib/gcc/BB_TARGET/13.2.0/include", + "-isystem /opt/BB_TARGET/lib/gcc/BB_TARGET/13.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++/13.2.0", + "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/13.2.0/BB_TARGET", + "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/13.2.0/backward", + "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/13.2.0/parallel", + ], + compiler = "compiler", + coverage_compile_flags = ["--coverage"], + coverage_link_flags = ["--coverage"], + cpu = "aarch64", cxx_builtin_include_directories = [ "/opt/BB_TARGET/lib/gcc/BB_TARGET/13.2.0/include", "/opt/BB_TARGET/lib/gcc/BB_TARGET/13.2.0/include-fixed", @@ -161,6 +177,27 @@ cc_toolchain_config( "/opt/BB_TARGET/BB_TARGET/include/c++/13.2.0/backward", "/opt/BB_TARGET/BB_TARGET/include/c++/13.2.0/parallel" ], + 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"], + # TODO gcc doesn't support it, only put it on clang (maybe even only for clang on aarch64-darwin?) + supports_start_end_lib = False, + target_libc = "", + target_system_name = "aarch64-unknown-linux-gnu", tool_paths = { "ar": "/opt/bin/BB_FULL_TARGET/ar", "as": "/opt/bin/BB_FULL_TARGET/as", @@ -189,38 +226,7 @@ cc_toolchain_config( "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 - "-isystem /opt/BB_TARGET/lib/gcc/BB_TARGET/13.2.0/include", - "-isystem /opt/BB_TARGET/lib/gcc/BB_TARGET/13.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++/13.2.0", - "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/13.2.0/BB_TARGET", - "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/13.2.0/backward", - "-isystem /opt/BB_TARGET/BB_TARGET/include/c++/13.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"], + toolchain_identifier = "ygg_aarch64", unfiltered_compile_flags = [ "-no-canonical-prefixes", "-Wno-builtin-macro-redefined", @@ -230,12 +236,6 @@ cc_toolchain_config( "-Wno-unused-command-line-argument", "-Wno-gnu-offsetof-extensions", ], - builtin_sysroot = "/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 = False, ) cc_toolchain( @@ -271,7 +271,8 @@ cc_toolchain_config( "/usr/include/c++/11", "/usr/include/x86_64-linux-gnu/c++/11", ], - dbg_compile_flags = ["-g", + dbg_compile_flags = [ + "-g", "-I/usr/include/c++/11", ], host_system_name = "linux", @@ -279,7 +280,7 @@ cc_toolchain_config( "-fuse-ld=lld", "--ld-path=/home/wmoses/llvms/llvm16/install/bin/ld.lld", "-stdlib=libstdc++", - "-static-libstdc++" + "-static-libstdc++", ], link_libs = [ "-lstdc++", @@ -304,9 +305,9 @@ cc_toolchain_config( # "/usr/bin/gcc": "/home/wmoses/git/Reactant.jl/deps/clang", # "gcc": "/home/wmoses/git/Reactant.jl/deps/clang", "gcc": "/home/wmoses/llvms/llvm16/install/bin/clang", - "g++": "/home/wmoses/llvms/llvm16/install/bin/clang++", - "cpp": "/home/wmoses/llvms/llvm16/install/bin/clang++", - "ld": "/home/wmoses/llvms/llvm16/install/bin/ld.lld", + "g++": "/home/wmoses/llvms/llvm16/install/bin/clang++", + "cpp": "/home/wmoses/llvms/llvm16/install/bin/clang++", + "ld": "/home/wmoses/llvms/llvm16/install/bin/ld.lld", }, toolchain_identifier = "beast_x86_toolchain", unfiltered_compile_flags = [ @@ -320,8 +321,6 @@ cc_toolchain_config( ], ) - - platform( name = "darwin_x86_64", constraint_values = [ @@ -330,7 +329,6 @@ platform( ], ) - platform( name = "darwin_arm64", constraint_values = [ @@ -358,13 +356,10 @@ platform( cc_library( name = "ReactantExtraLib", srcs = glob( - [ - "*.cpp", - ], - + ["src/*.cpp"], ) + [ - "@enzyme_ad//src/enzyme_ad/jax:RegistryUtils.cpp", - "@enzyme_ad//src/enzyme_ad/jax:gpu.cc", + "@enzyme_ad//src/enzyme_ad/jax:RegistryUtils.cpp", + "@enzyme_ad//src/enzyme_ad/jax:gpu.cc", # "@com_google_protobuf//:src/google/protobuf/io/coded_stream.cc", # "@xla//xla:xla.pb.cc", "@xla//xla:xla_data.pb.cc", @@ -377,7 +372,7 @@ cc_library( "@xla//xla:autotuning.pb.cc", "@xla//xla:autotune_results.pb.cc", "@xla//xla/service:buffer_assignment.pb.cc", - ], + ], hdrs = glob([ "*.h", ]), @@ -386,58 +381,18 @@ cc_library( "-Werror=unused-but-set-variable", "-Werror=return-type", "-Werror=unused-result", - "-Wno-error=stringop-truncation" + "-Wno-error=stringop-truncation", ], - alwayslink = True, - linkstatic = True, linkopts = select({ - "//conditions:default": [], - "@bazel_tools//src/conditions:darwin": [ -"-Wl,-exported_symbol,_stablehlo*", -"-Wl,-exported_symbol,_mlir*", -"-Wl,-exported_symbol,_InitializeLogs", -"-Wl,-exported_symbol,_SetLogLevel", -"-Wl,-exported_symbol,_SetModuleLogLevel", -"-Wl,-exported_symbol,_GetDefaultTargetTriple", -"-Wl,-exported_symbol,_enzymeActivityAttrGet", -"-Wl,-exported_symbol,_MakeCPUClient", -"-Wl,-exported_symbol,_MakeGPUClient", -"-Wl,-exported_symbol,_MakeTPUClient", -"-Wl,-exported_symbol,_LoadPjrtPlugin", -"-Wl,-exported_symbol,_InitializePjrtPlugin", -"-Wl,-exported_symbol,_GetCApiClient", -"-Wl,-exported_symbol,_ClientNumDevices", -"-Wl,-exported_symbol,_ClientNumAddressableDevices", -"-Wl,-exported_symbol,_ClientProcessIndex", -"-Wl,-exported_symbol,_ClientGetDevice", -"-Wl,-exported_symbol,_ClientGetAddressableDevice", -"-Wl,-exported_symbol,_ExecutableFree", -"-Wl,-exported_symbol,_BufferToDevice", -"-Wl,-exported_symbol,_BufferToClient", -"-Wl,-exported_symbol,_DeviceToClient", -"-Wl,-exported_symbol,_PjRtBufferFree", -"-Wl,-exported_symbol,_UnsafeBufferPointer", -"-Wl,-exported_symbol,_ArrayFromHostBuffer", -"-Wl,-exported_symbol,_BufferOnCPU", -"-Wl,-exported_symbol,_CopyBufferToDevice", -"-Wl,-exported_symbol,_BufferToHost", -"-Wl,-exported_symbol,_FreeClient", -"-Wl,-exported_symbol,_ClientCompile", -"-Wl,-exported_symbol,_LinkInModule", -"-Wl,-exported_symbol,_FreeFuture", -"-Wl,-exported_symbol,_FutureIsReady", -"-Wl,-exported_symbol,_FutureAwait", -"-Wl,-exported_symbol,_XLAExecute", -"-Wl,-exported_symbol,_RegisterDialects", -"-Wl,-exported_symbol,_InitializeRegistryAndPasses", -"-Wl,-exported_symbol,_ifrt_*", -"-Wl,-exported_symbol,_RegisterCustomCallTarget", -"-Wl,-exported_symbol,_ConvertLLVMToMLIR", -"-Wl,-exported_symbol,_RegisterEnzymeXLAGPUHandler", -"-Wl,-exported_symbol,_ReactantThrowError", - ]}), + "//conditions:default": [], + "@bazel_tools//src/conditions:darwin": [ + "-fvisibility=default", + "-Wl,-unexported_symbol,_*llvm*", + ], + }), + linkstatic = True, deps = [ - "@enzyme//:EnzymeMLIR", + "@enzyme//:EnzymeMLIR", "@llvm-project//mlir:AffineDialect", "@llvm-project//mlir:AllPassesAndDialects", "@llvm-project//mlir:ArithDialect", @@ -460,11 +415,9 @@ cc_library( "@llvm-project//mlir:SCFDialect", "@llvm-project//mlir:TransformDialect", "@llvm-project//mlir:Transforms", - "@llvm-project//mlir:LLVMIRToLLVMTranslation", "@llvm-project//mlir:LLVMIRToNVVMTranslation", "@llvm-project//mlir:LLVMIRTransforms", - "@llvm-project//llvm:IRReader", "@llvm-project//llvm:Support", "@llvm-project//llvm:AArch64AsmParser", @@ -480,31 +433,25 @@ cc_library( "@xla//xla/pjrt:pjrt_api", "@xla//xla/pjrt:pjrt_c_api_client", "@xla//xla/pjrt/cpu:cpu_client", - "@xla//xla:xla_proto_cc", "@xla//xla:xla_proto_cc_impl", - "@xla//xla/service:metrics_proto_cc", "@xla//xla/service:metrics_proto_cc_impl", - "@xla//xla/service/cpu:cpu_compiler", "@xla//xla/stream_executor/tpu:tpu_on_demand_compiler", "@xla//xla/stream_executor/tpu:tpu_executor", "@xla//xla/stream_executor/tpu:tpu_transfer_manager", - "@xla//xla/service/cpu:cpu_transfer_manager", "@xla//xla/pjrt/gpu:se_gpu_pjrt_client", - - "@xla//xla/tsl/protobuf:protos_all_cc_impl", + "@xla//xla/tsl/protobuf:protos_all_cc_impl", "@xla//xla/tsl/framework:allocator_registry_impl", - "@xla//xla/pjrt:status_casters", - "@xla//xla/python/ifrt:ifrt", - "@xla//xla/python/pjrt_ifrt:pjrt_ifrt", + "@xla//xla/python/ifrt", + "@xla//xla/python/pjrt_ifrt", "@xla//xla/python/ifrt/hlo:hlo_program", "@xla//xla/ffi:call_frame", "@com_google_protobuf//:protobuf", - "@xla//xla/tsl/profiler/backends/cpu:annotation_stack_impl", + "@xla//xla/tsl/profiler/backends/cpu:annotation_stack_impl", "@xla//xla/tsl/profiler/backends/cpu:traceme_recorder_impl", "@xla//xla/tsl/profiler/utils:time_utils_impl", "@tsl//tsl/platform:env_impl", @@ -512,36 +459,43 @@ cc_library( "@xla//xla/mlir/utils:type_util", "@stablehlo//:stablehlo_capi_objects", "@stablehlo//:chlo_capi_objects", - "@com_google_absl//absl/hash:hash", + "@com_google_absl//absl/hash", "@com_google_absl//absl/log:initialize", "@com_google_absl//absl/log:globals", "@llvm-project//mlir:CAPIIRObjects", ] + select({ - "@xla//xla/tsl:is_cuda_enabled_and_oss":[ - "@xla//xla/stream_executor/cuda:all_runtime", - "@xla//xla/service/gpu/model:hlo_op_profiles", - "@xla//xla/service/gpu/model:hlo_op_profile_proto_cc_impl", - "@xla//xla/service/gpu:nvptx_compiler", - "@xla//xla/service/gpu:gpu_transfer_manager", - "@xla//xla/stream_executor:kernel", - ], - "//conditions:default": [], + "@xla//xla/tsl:is_cuda_enabled_and_oss": [ + "@xla//xla/service/gpu:gpu_transfer_manager", + "@xla//xla/service/gpu:nvptx_compiler", + "@xla//xla/service/gpu/model:hlo_op_profile_proto_cc_impl", + "@xla//xla/service/gpu/model:hlo_op_profiles", + "@xla//xla/stream_executor:kernel", + "@xla//xla/stream_executor/cuda:all_runtime", + ], + "//conditions:default": [], }) + if_rocm([ "@xla//xla/service/gpu:amdgpu_compiler", ]), + alwayslink = True, ) # cc_shared_library( cc_binary( name = "libReactantExtra.so", - linkshared = 1, ## important - linkstatic = 1, ## important + linkshared = 1, ## important + linkstatic = 1, ## important deps = [":ReactantExtraLib"], ) cc_binary( name = "mlir-jl-tblgen", - srcs = ["//tblgen:mlir-jl-tblgen.cc", "//tblgen:jl-generators.cc"], + srcs = [ + "//tblgen:jl-generators.cc", + "//tblgen:mlir-jl-tblgen.cc", + ], + tags = [ + "optional", + ], visibility = ["//visibility:public"], deps = [ "@llvm-project//llvm:Support", @@ -549,143 +503,173 @@ cc_binary( "@llvm-project//llvm:config", "@llvm-project//mlir:TableGen", ], - tags = [ - "optional" - ], ) gentbl_cc_library( name = "BuiltinJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "Builtin.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "Builtin.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@llvm-project//mlir:include/mlir/IR/BuiltinOps.td", deps = [ "@llvm-project//mlir:BuiltinDialectTdFiles", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "ArithJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "Arith.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "Arith.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@llvm-project//mlir:include/mlir/Dialect/Arith/IR/ArithOps.td", deps = [ "@llvm-project//mlir:ArithOpsTdFiles", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "AffineJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "Affine.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "Affine.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@llvm-project//mlir:include/mlir/Dialect/Affine/IR/AffineOps.td", deps = [ "@llvm-project//mlir:AffineOpsTdFiles", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "FuncJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "Func.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "Func.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@llvm-project//mlir:include/mlir/Dialect/Func/IR/FuncOps.td", deps = [ "@llvm-project//mlir:FuncTdFiles", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "EnzymeJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "Enzyme.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "Enzyme.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@enzyme//:Enzyme/MLIR/Dialect/EnzymeOps.td", deps = [ "@enzyme//:EnzymeDialectTdFiles", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "EnzymeXLAJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "EnzymeXLA.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "EnzymeXLA.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@enzyme_ad//src/enzyme_ad/jax:Dialect/EnzymeXLAOps.td", deps = [ "@enzyme//:EnzymeDialectTdFiles", "@enzyme_ad//src/enzyme_ad/jax:EnzymeXLADialectTdFiles", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "StableHLOJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "StableHLO.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "StableHLO.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@stablehlo//:stablehlo/dialect/StablehloOps.td", deps = [ "@stablehlo//:stablehlo_ops_td_files", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "CHLOJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "CHLO.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "CHLO.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@stablehlo//:stablehlo/dialect/ChloOps.td", deps = [ "@stablehlo//:chlo_ops_td_files", ], - tblgen = "//:mlir-jl-tblgen", ) gentbl_cc_library( name = "VHLOJLIncGen", - tbl_outs = [( - ["--generator=jl-op-defs", "--disable-module-wrap=0"], - "VHLO.jl" - ) + tbl_outs = [ + ( + [ + "--generator=jl-op-defs", + "--disable-module-wrap=0", + ], + "VHLO.jl", + ), ], + tblgen = "//:mlir-jl-tblgen", td_file = "@stablehlo//:stablehlo/dialect/VhloOps.td", deps = [ "@stablehlo//:vhlo_ops_td_files", ], - tblgen = "//:mlir-jl-tblgen", ) genrule( name = "libMLIR_h.jl", - tags = [ - "jlrule" - ], srcs = [ "@llvm-project//mlir:include/mlir-c/Bindings/Python/Interop.h", "@llvm-project//llvm:include/llvm-c/Support.h", @@ -704,8 +688,11 @@ genrule( "//:Manifest.toml", "//:wrap.toml", "//:missing_defs.jl", - "//:make.jl" + "//:make.jl", ], outs = ["libMLIR_h.jl"], cmd = "$$JULIA \"--project=$(location //:Project.toml)\" \"$(location //:make.jl)\" \"$(location @llvm-project//mlir:include/mlir-c/Bindings/Python/Interop.h)\" \"$(location @llvm-project//llvm:include/llvm-c/Support.h)\" \"$(locations @llvm-project//mlir:ConversionPassIncGen_filegroup)\" \"$(location @stablehlo//:stablehlo/integrations/c/StablehloAttributes.h)\" \"$@\"", + tags = [ + "jlrule", + ], ) diff --git a/deps/ReactantExtra/WORKSPACE b/deps/ReactantExtra/WORKSPACE index 95c2b7bb9..b7fc309e9 100644 --- a/deps/ReactantExtra/WORKSPACE +++ b/deps/ReactantExtra/WORKSPACE @@ -1,121 +1,29 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -NSYNC_COMMIT = "82b118aa7ace3132e517e2c467f8732978cf4023" -NSYNC_SHA256 = "" -http_archive( - name = "nsync", - sha256 = NSYNC_SHA256, - strip_prefix = "nsync-" + NSYNC_COMMIT, - urls = ["https://github.com/wsmoses/nsync/archive/{commit}.tar.gz".format(commit = NSYNC_COMMIT)], -) - -ENZYMEXLA_COMMIT = "74046d05089c02946058f8fd94ed23efd0bf3ccc" -ENZYMEXLA_SHA256 = "" - -http_archive( - name = "enzyme_ad", - sha256 = ENZYMEXLA_SHA256, - strip_prefix = "Enzyme-JAX-" + ENZYMEXLA_COMMIT, - urls = ["https://github.com/EnzymeAD/Enzyme-JAX/archive/{commit}.tar.gz".format(commit = ENZYMEXLA_COMMIT)], -) - - -http_archive( - name = "rules_python", - sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618", - strip_prefix = "rules_python-0.34.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", -) +workspace(name = "Reactant") -# Hedron's Compile Commands Extractor for Bazel -# https://github.com/hedronvision/bazel-compile-commands-extractor -http_archive( - name = "hedron_compile_commands", +load("//third_party/nsync:workspace.bzl", nsync_workspace = "repo") +nsync_workspace() - # Replace the commit hash (0e990032f3c5a866e72615cf67e5ce22186dcb97) in both places (below) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main), rather than using the stale one here. - # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README). - url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/4f28899228fb3ad0126897876f147ca15026151e.tar.gz", - strip_prefix = "bazel-compile-commands-extractor-4f28899228fb3ad0126897876f147ca15026151e", - # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..." -) -load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") -hedron_compile_commands_setup() -load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive") -hedron_compile_commands_setup_transitive() -load("@hedron_compile_commands//:workspace_setup_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive") -hedron_compile_commands_setup_transitive_transitive() -load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive") -hedron_compile_commands_setup_transitive_transitive_transitive() +load("//third_party/rules_python:workspace.bzl", rules_python_workspace = "repo") +rules_python_workspace() -load("@enzyme_ad//:workspace.bzl", "JAX_COMMIT", "JAX_SHA256", "ENZYME_COMMIT", "ENZYME_SHA256", "XLA_PATCHES") - -XLA_PATCHES = XLA_PATCHES + [ -""" -sed -i.bak0 "s/__cpp_lib_hardware_interference_size/HW_INTERFERENCE_SIZE/g" xla/backends/cpu/runtime/thunk_executor.h -""", -""" -sed -i.bak0 "s/__cpp_lib_hardware_interference_size/HW_INTERFERENCE_SIZE/g" xla/stream_executor/host/host_kernel.cc -""", -""" -sed -i.bak0 "s/__cpp_lib_hardware_interference_size/HW_INTERFERENCE_SIZE/g" xla/tsl/concurrency/async_value_ref.h -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_LINK_H=1\\/HAVE_LINK_H=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/LLVM_ENABLE_THREADS=1\\/LLVM_ENABLE_THREADS=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_MALLINFO=1\\/DONT_HAVE_ANY_MALLINFO=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_PTHREAD_GETNAME_NP=1\\/FAKE_HAVE_PTHREAD_GETNAME_NP=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_PTHREAD_SETNAME_NP=1\\/FAKE_HAVE_PTHREAD_SETNAME_NP=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.h -exec sed -i.bak0 's\\/ENABLE_CRASH_OVERRIDES 1\\/ENABLE_CRASH_OVERRIDES 0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.h -exec sed -i.bak0 's\\/HAVE_PTHREAD_GETNAME_NP\\/FAKE_HAVE_PTHREAD_GETNAME_NP\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -""" -sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.h -exec sed -i.bak0 's\\/HAVE_PTHREAD_SETNAME_NP\\/FAKE_HAVE_PTHREAD_SETNAME_NP\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl -""", -# """ -# sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\['find . -type f -name BUILD.bazel -exec sed -i.bak0 \\\\\\'s\\/\\\"CAPIIR\\\",\\/\\\"CAPIIR\\\",alwayslink=1,\\/g\\\\\\\\' {} +',/g" third_party/llvm/workspace.bzl -# """, -] +load("//third_party/enzyme_ad:workspace.bzl", enzyme_ad_workspace = "repo") +enzyme_ad_workspace() -LLVM_TARGETS = select({ - "@bazel_tools//src/conditions:windows": ["AMDGPU", "NVPTX"], - "@bazel_tools//src/conditions:darwin": [], - "//conditions:default": ["AMDGPU", "NVPTX"], -}) + ["AArch64", "X86", "ARM"] +load("//third_party/rules_cc:workspace.bzl", rules_cc_workspace = "repo") +rules_cc_workspace() -http_archive( - name = "jax", - sha256 = JAX_SHA256, - strip_prefix = "jax-" + JAX_COMMIT, - urls = ["https://github.com/google/jax/archive/{commit}.tar.gz".format(commit = JAX_COMMIT)], - patch_args = ["-p1"], - patches = ["@enzyme_ad//:patches/jax.patch"], -) +load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies") +rules_cc_dependencies() -load("@jax//third_party/xla:workspace.bzl", "XLA_COMMIT", "XLA_SHA256") +load("//third_party/jax:workspace.bzl", jax_workspace = "repo") +jax_workspace() -http_archive( - name = "xla", - sha256 = XLA_SHA256, - strip_prefix = "xla-" + XLA_COMMIT, - urls = ["https://github.com/wsmoses/xla/archive/{commit}.tar.gz".format(commit = XLA_COMMIT)], - patch_cmds = XLA_PATCHES -) +load("//third_party/xla:workspace.bzl", xla_workspace = "repo") +xla_workspace() load("@xla//third_party/py:python_init_rules.bzl", "python_init_rules") python_init_rules() - + load("@xla//third_party/py:python_init_repositories.bzl", "python_init_repositories") python_init_repositories( requirements = { @@ -126,7 +34,7 @@ python_init_repositories( "3.13": "//build:requirements_lock_3_13.txt", }, ) - + load("@xla//third_party/py:python_init_toolchains.bzl", "python_init_toolchains") python_init_toolchains() # @@ -144,42 +52,24 @@ python_init_toolchains() # # pip_install_dependencies() -http_archive( - name = "enzyme", - sha256 = ENZYME_SHA256, - strip_prefix = "Enzyme-" + ENZYME_COMMIT + "/enzyme", - urls = ["https://github.com/EnzymeAD/Enzyme/archive/{commit}.tar.gz".format(commit = ENZYME_COMMIT)], -) +load("//third_party/enzyme:workspace.bzl", enzyme_workspace = "repo") +enzyme_workspace() -http_archive( - name = "build_bazel_rules_apple", - sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7", - url = "https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz", -) +load("//third_party/build_bazel_rules_apple:workspace.bzl", build_bazel_rules_apple_workspace = "repo") +build_bazel_rules_apple_workspace() load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) - apple_rules_dependencies() - -http_archive( - name = "upb", - sha256 = "61d0417abd60e65ed589c9deee7c124fe76a4106831f6ad39464e1525cef1454", - strip_prefix = "upb-9effcbcb27f0a665f9f345030188c0b291e32482", - patch_cmds = [ - "sed -i.bak0 's/@bazel_tools\\/\\/platforms:windows/@platforms\\/\\/os:windows/g' BUILD", - "sed -i.bak0 's/-Werror//g' BUILD" - ], - url = "https://github.com/protocolbuffers/upb/archive/9effcbcb27f0a665f9f345030188c0b291e32482.tar.gz" -) +load("//third_party/upb:workspace.bzl", upb_workspace = "repo") +upb_workspace() load("@jax//third_party/xla:workspace.bzl", jax_xla_workspace = "repo") jax_xla_workspace() - load("@xla//:workspace4.bzl", "xla_workspace4") xla_workspace4() @@ -188,6 +78,12 @@ xla_workspace3() load("@xla//:workspace2.bzl", "xla_workspace2") +LLVM_TARGETS = select({ + "@bazel_tools//src/conditions:windows": ["AMDGPU", "NVPTX"], + "@bazel_tools//src/conditions:darwin": [], + "//conditions:default": ["AMDGPU", "NVPTX"], +}) + ["AArch64", "X86", "ARM"] + load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure") llvm_configure(name = "llvm-project", targets = LLVM_TARGETS) xla_workspace2() @@ -205,7 +101,6 @@ load( "@tsl//third_party/gpus/cuda/hermetic:cuda_json_init_repository.bzl", "cuda_json_init_repository", ) - cuda_json_init_repository() load( @@ -218,11 +113,9 @@ load( "cuda_redist_init_repositories", "cudnn_redist_init_repository", ) - cuda_redist_init_repositories( cuda_redistributions = CUDA_REDISTRIBUTIONS, ) - cudnn_redist_init_repository( cudnn_redistributions = CUDNN_REDISTRIBUTIONS, ) @@ -231,19 +124,31 @@ load( "@tsl//third_party/gpus/cuda/hermetic:cuda_configure.bzl", "cuda_configure", ) - cuda_configure(name = "local_config_cuda") load( "@tsl//third_party/nccl/hermetic:nccl_redist_init_repository.bzl", "nccl_redist_init_repository", ) - nccl_redist_init_repository() load( "@tsl//third_party/nccl/hermetic:nccl_configure.bzl", "nccl_configure", ) - nccl_configure(name = "local_config_nccl") + +load("@enzyme_ad//third_party/hedron_compile_commands:workspace.bzl", hedron_compile_commands_workspace = "repo") +hedron_compile_commands_workspace() + +load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") +hedron_compile_commands_setup() + +load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive") +hedron_compile_commands_setup_transitive() + +load("@hedron_compile_commands//:workspace_setup_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive") +hedron_compile_commands_setup_transitive_transitive() + +load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive") +hedron_compile_commands_setup_transitive_transitive_transitive() diff --git a/deps/ReactantExtra/API.cpp b/deps/ReactantExtra/src/API.cpp similarity index 100% rename from deps/ReactantExtra/API.cpp rename to deps/ReactantExtra/src/API.cpp diff --git a/deps/ReactantExtra/third_party/BUILD b/deps/ReactantExtra/third_party/BUILD new file mode 100644 index 000000000..b2c46fa7a --- /dev/null +++ b/deps/ReactantExtra/third_party/BUILD @@ -0,0 +1 @@ +licenses(["notice"]) \ No newline at end of file diff --git a/deps/ReactantExtra/third_party/build_bazel_rules_apple/BUILD b/deps/ReactantExtra/third_party/build_bazel_rules_apple/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/build_bazel_rules_apple/workspace.bzl b/deps/ReactantExtra/third_party/build_bazel_rules_apple/workspace.bzl new file mode 100644 index 000000000..f4350d99a --- /dev/null +++ b/deps/ReactantExtra/third_party/build_bazel_rules_apple/workspace.bzl @@ -0,0 +1,10 @@ +"""Loads bazel rules for apple.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def repo(): + http_archive( + name = "build_bazel_rules_apple", + sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7", + url = "https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz", + ) diff --git a/deps/ReactantExtra/third_party/enzyme/BUILD b/deps/ReactantExtra/third_party/enzyme/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/enzyme/workspace.bzl b/deps/ReactantExtra/third_party/enzyme/workspace.bzl new file mode 100644 index 000000000..c7db5aef4 --- /dev/null +++ b/deps/ReactantExtra/third_party/enzyme/workspace.bzl @@ -0,0 +1,12 @@ +"""Loads Enzyme.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@enzyme_ad//:workspace.bzl", "ENZYME_COMMIT", "ENZYME_SHA256") + +def repo(): + http_archive( + name = "enzyme", + sha256 = ENZYME_SHA256, + strip_prefix = "Enzyme-" + ENZYME_COMMIT + "/enzyme", + urls = ["https://github.com/EnzymeAD/Enzyme/archive/{commit}.tar.gz".format(commit = ENZYME_COMMIT)], + ) diff --git a/deps/ReactantExtra/third_party/enzyme_ad/BUILD b/deps/ReactantExtra/third_party/enzyme_ad/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/enzyme_ad/workspace.bzl b/deps/ReactantExtra/third_party/enzyme_ad/workspace.bzl new file mode 100644 index 000000000..e02b73579 --- /dev/null +++ b/deps/ReactantExtra/third_party/enzyme_ad/workspace.bzl @@ -0,0 +1,12 @@ +"""Loads Enzyme-JAX.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "ENZYMEXLA_COMMIT", "ENZYMEXLA_SHA256") + +def repo(): + http_archive( + name = "enzyme_ad", + sha256 = ENZYMEXLA_SHA256, + strip_prefix = "Enzyme-JAX-" + ENZYMEXLA_COMMIT, + urls = ["https://github.com/EnzymeAD/Enzyme-JAX/archive/{commit}.tar.gz".format(commit = ENZYMEXLA_COMMIT)], + ) diff --git a/deps/ReactantExtra/third_party/jax/BUILD b/deps/ReactantExtra/third_party/jax/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/jax/workspace.bzl b/deps/ReactantExtra/third_party/jax/workspace.bzl new file mode 100644 index 000000000..53e0cac75 --- /dev/null +++ b/deps/ReactantExtra/third_party/jax/workspace.bzl @@ -0,0 +1,14 @@ +"""Loads Enzyme-JAX.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@enzyme_ad//:workspace.bzl", "JAX_COMMIT", "JAX_SHA256") + +def repo(): + http_archive( + name = "jax", + sha256 = JAX_SHA256, + strip_prefix = "jax-" + JAX_COMMIT, + urls = ["https://github.com/google/jax/archive/{commit}.tar.gz".format(commit = JAX_COMMIT)], + patch_args = ["-p1"], + patches = ["@enzyme_ad//:patches/jax.patch"], + ) diff --git a/deps/ReactantExtra/third_party/nsync/BUILD b/deps/ReactantExtra/third_party/nsync/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/nsync/workspace.bzl b/deps/ReactantExtra/third_party/nsync/workspace.bzl new file mode 100644 index 000000000..53dac7f67 --- /dev/null +++ b/deps/ReactantExtra/third_party/nsync/workspace.bzl @@ -0,0 +1,12 @@ +"""Loads nsync.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "NSYNC_COMMIT", "NSYNC_SHA256") + +def repo(): + http_archive( + name = "nsync", + sha256 = NSYNC_SHA256, + strip_prefix = "nsync-" + NSYNC_COMMIT, + urls = ["https://github.com/wsmoses/nsync/archive/{commit}.tar.gz".format(commit = NSYNC_COMMIT)], + ) diff --git a/deps/ReactantExtra/third_party/rules_cc/BUILD b/deps/ReactantExtra/third_party/rules_cc/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/rules_cc/workspace.bzl b/deps/ReactantExtra/third_party/rules_cc/workspace.bzl new file mode 100644 index 000000000..b7e8d25a6 --- /dev/null +++ b/deps/ReactantExtra/third_party/rules_cc/workspace.bzl @@ -0,0 +1,14 @@ +"""Loads bazel rules_cc.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "RULES_CC_COMMIT", "RULES_CC_SHA256") + +def repo(): + http_archive( + name = "rules_cc", + sha256 = RULES_CC_SHA256, + strip_prefix = "rules_cc-" + RULES_CC_COMMIT, + urls = [ + "https://github.com/bazelbuild/rules_cc/archive/{commit}.tar.gz".format(commit = RULES_CC_COMMIT), + ], + ) diff --git a/deps/ReactantExtra/third_party/rules_python/BUILD b/deps/ReactantExtra/third_party/rules_python/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/rules_python/workspace.bzl b/deps/ReactantExtra/third_party/rules_python/workspace.bzl new file mode 100644 index 000000000..10db7c2fa --- /dev/null +++ b/deps/ReactantExtra/third_party/rules_python/workspace.bzl @@ -0,0 +1,12 @@ +"""Loads rules_python (downgrades over the one used by XLA due to a bug in the latest release).""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "RULES_PYTHON_SHA256", "RULES_PYTHON_VERSION") + +def repo(): + http_archive( + name = "rules_python", + sha256 = RULES_PYTHON_SHA256, + strip_prefix = "rules_python-" + RULES_PYTHON_VERSION, + url = "https://github.com/bazelbuild/rules_python/releases/download/{commit}/rules_python-{commit}.tar.gz".format(commit = RULES_PYTHON_VERSION), + ) diff --git a/deps/ReactantExtra/third_party/upb/BUILD b/deps/ReactantExtra/third_party/upb/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/upb/workspace.bzl b/deps/ReactantExtra/third_party/upb/workspace.bzl new file mode 100644 index 000000000..100f0c28a --- /dev/null +++ b/deps/ReactantExtra/third_party/upb/workspace.bzl @@ -0,0 +1,16 @@ +"""Loads upb.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//:workspace.bzl", "UPB_COMMIT", "UPB_SHA256") + +def repo(): + http_archive( + name = "upb", + sha256 = UPB_SHA256, + strip_prefix = "upb-" + UPB_COMMIT, + patch_cmds = [ + "sed -i.bak0 's/@bazel_tools\\/\\/platforms:windows/@platforms\\/\\/os:windows/g' BUILD", + "sed -i.bak0 's/-Werror//g' BUILD", + ], + url = "https://github.com/protocolbuffers/upb/archive/{commit}.tar.gz".format(commit = UPB_COMMIT), + ) diff --git a/deps/ReactantExtra/third_party/xla/BUILD b/deps/ReactantExtra/third_party/xla/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/deps/ReactantExtra/third_party/xla/workspace.bzl b/deps/ReactantExtra/third_party/xla/workspace.bzl new file mode 100644 index 000000000..dd2479db3 --- /dev/null +++ b/deps/ReactantExtra/third_party/xla/workspace.bzl @@ -0,0 +1,26 @@ +"""Loads XLA.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@enzyme_ad//:workspace.bzl", "XLA_PATCHES") +load("@jax//third_party/xla:workspace.bzl", "XLA_COMMIT", "XLA_SHA256") + +def repo(): + http_archive( + name = "xla", + sha256 = XLA_SHA256, + strip_prefix = "xla-" + XLA_COMMIT, + urls = ["https://github.com/wsmoses/xla/archive/{commit}.tar.gz".format(commit = XLA_COMMIT)], + patch_cmds = XLA_PATCHES + [ + """sed -i.bak0 "s/__cpp_lib_hardware_interference_size/HW_INTERFERENCE_SIZE/g" xla/backends/cpu/runtime/thunk_executor.h""", + """sed -i.bak0 "s/__cpp_lib_hardware_interference_size/HW_INTERFERENCE_SIZE/g" xla/stream_executor/host/host_kernel.cc""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_LINK_H=1\\/HAVE_LINK_H=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/LLVM_ENABLE_THREADS=1\\/LLVM_ENABLE_THREADS=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_MALLINFO=1\\/DONT_HAVE_ANY_MALLINFO=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_PTHREAD_GETNAME_NP=1\\/FAKE_HAVE_PTHREAD_GETNAME_NP=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.bzl -exec sed -i.bak0 's\\/HAVE_PTHREAD_SETNAME_NP=1\\/FAKE_HAVE_PTHREAD_SETNAME_NP=0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.h -exec sed -i.bak0 's\\/ENABLE_CRASH_OVERRIDES 1\\/ENABLE_CRASH_OVERRIDES 0\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.h -exec sed -i.bak0 's\\/HAVE_PTHREAD_GETNAME_NP\\/FAKE_HAVE_PTHREAD_GETNAME_NP\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\[\\\"find . -type f -name config.h -exec sed -i.bak0 's\\/HAVE_PTHREAD_SETNAME_NP\\/FAKE_HAVE_PTHREAD_SETNAME_NP\\/g' {} +\\\",/g" third_party/llvm/workspace.bzl""", + # """sed -i.bak0 "s/patch_cmds = \\[/patch_cmds = \\['find . -type f -name BUILD.bazel -exec sed -i.bak0 \\\\\\'s\\/\\\"CAPIIR\\\",\\/\\\"CAPIIR\\\",alwayslink=1,\\/g\\\\\\\\' {} +',/g" third_party/llvm/workspace.bzl""", + ], + ) diff --git a/deps/ReactantExtra/tools/platforms.bzl b/deps/ReactantExtra/tools/platforms.bzl new file mode 100644 index 000000000..da7dfc796 --- /dev/null +++ b/deps/ReactantExtra/tools/platforms.bzl @@ -0,0 +1,31 @@ +platform( + name = "darwin_x86_64", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:x86_64", + ], +) + +platform( + name = "darwin_arm64", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:arm64", + ], +) + +platform( + name = "linux_x86_64", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], +) + +platform( + name = "linux_aarch64", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:aarch64", + ], +) diff --git a/deps/ReactantExtra/toolchain/yggdrasil.bzl b/deps/ReactantExtra/tools/toolchains/yggdrasil/BUILD similarity index 100% rename from deps/ReactantExtra/toolchain/yggdrasil.bzl rename to deps/ReactantExtra/tools/toolchains/yggdrasil/BUILD diff --git a/deps/ReactantExtra/workspace.bzl b/deps/ReactantExtra/workspace.bzl new file mode 100644 index 000000000..3da44029e --- /dev/null +++ b/deps/ReactantExtra/workspace.bzl @@ -0,0 +1,14 @@ +ENZYMEXLA_COMMIT = "52e14543628df5e3f806dce096243c4603d3e103" +ENZYMEXLA_SHA256 = "" + +NSYNC_COMMIT = "82b118aa7ace3132e517e2c467f8732978cf4023" +NSYNC_SHA256 = "" + +RULES_CC_COMMIT = "c8c38f8c710cbbf834283e4777916b68261b359c" +RULES_CC_SHA256 = "85723d827f080c5e927334f1fb18a294c0b3f94fee6d6b45945f5cdae6ea0fd4" + +RULES_PYTHON_VERSION = "0.34.0" +RULES_PYTHON_SHA256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618" + +UPB_COMMIT = "9effcbcb27f0a665f9f345030188c0b291e32482" +UPB_SHA256 = "61d0417abd60e65ed589c9deee7c124fe76a4106831f6ad39464e1525cef1454" diff --git a/deps/clang b/deps/clang deleted file mode 100755 index 77df2a34c..000000000 --- a/deps/clang +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -/home/wmoses/llvms/llvm16/install/bin/clang -I/usr/include/x86_64-linux-gnu/c++/11 -L/home/wmoses/llvms/llvm16/build/lib/x86_64-unknown-linux-gnu -stdlib=libc++ -v "$@" diff --git a/deps/clang++ b/deps/clang++ deleted file mode 100755 index 25b16f719..000000000 --- a/deps/clang++ +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -/home/wmoses/llvms/llvm16/build/bin/clang++ -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -L/usr/lib/x86_64-linux-gnu "$@" diff --git a/deps/gcc b/deps/gcc deleted file mode 100755 index d92c9c10d..000000000 --- a/deps/gcc +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# /usr/local/cuda/bin/nvcc "$@" -/home/wmoses/llvms/llvm16/install/bin/clang -Xclang -fcuda-allow-variadic-functions -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -Wno-unused-command-line-argument -L/usr/lib/gcc/x86_64-linux-gnu/11 -static-libstdc++ "$@" || /home/wmoses/llvms/llvm16/install/bin/clang -Xclang -fcuda-allow-variadic-functions -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -Wno-unused-command-line-argument -L/usr/lib/gcc/x86_64-linux-gnu/11 -static-libstdc++ -g0 "$@" -g0