gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/sentry/platform/systrap/sysmsg/build.bzl (about) 1 """Sysmsg rules.""" 2 3 load("//tools:arch.bzl", "select_arch") 4 load("//tools:defs.bzl", "cc_toolchain") 5 6 def cc_pie_obj(name, srcs, outs): 7 native.genrule( 8 name = name, 9 srcs = srcs, 10 outs = outs, 11 cmd = "$(CC) $(CC_FLAGS) " + 12 "-Wall -Werror -Wno-unused-command-line-argument " + 13 "-fpie " + 14 # -01 is required for clang to avoid making use of memcpy when 15 # building for ARM64. For some reason when no optimization is turned 16 # on clang makes use of memcpy to copy structures and when combined 17 # with -ffreestanding it means we need to provide our own version of 18 # memcpy. Using -01 causes clang to not make use of memcpy avoiding 19 # the need to supply our own memcpy version. 20 select_arch( 21 amd64 = "-O2", 22 arm64 = "-O1 -mno-outline-atomics ", 23 ) + 24 " -fno-builtin " + 25 "-ffreestanding " + 26 "-mgeneral-regs-only " + 27 # Set -g0 to omit debugging information because it contains 28 # absolute paths, which are volatile build information and results 29 # in Bazel being unable to properly cache the output. If debugging 30 # information is desired, the flags -fdebug-compilation-dir or 31 # -fdebug-prefix-map can be used. 32 "-g0 " + 33 "-Wa,--noexecstack " + 34 "-fno-asynchronous-unwind-tables " + 35 "-fno-stack-protector " + 36 "-c $$(echo $(SRCS) | tr ' ' '\n' | grep -v -E '.h$$') -o $@", 37 toolchains = [ 38 ":no_pie_cc_flags", 39 cc_toolchain, 40 ], 41 )