Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--per_file_copt=external/.* no longer working in Bazel 7.4 #24528

Closed
mering opened this issue Nov 29, 2024 · 11 comments
Closed

--per_file_copt=external/.* no longer working in Bazel 7.4 #24528

mering opened this issue Nov 29, 2024 · 11 comments
Labels
team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged

Comments

@mering
Copy link

mering commented Nov 29, 2024

Description of the bug:

We use the following to disable warnings on external dependencies and build our own code with -Werror:

build --per_file_copt=external/.*@-Wno-everything
build --copt=-Werror --host_copt=-Werror

Unfortunately, this does no longer work in Bazel 7.4 (it worked before) and the external/.* regex doesn't seem to catch external paths any more (even though the paths in the warnings/errors start with external/).

How can I match all external repos with --per_file_copt in Bazel 7.4?

Which category does this issue belong to?

Core

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

This might be limited to non-module dependencies.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

7.4.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

It worked in Bazel 7.0.2 but our repo doesn't build with the old version any more.

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@github-actions github-actions bot added the team-Core Skyframe, bazel query, BEP, options parsing, bazelrc label Nov 29, 2024
@fmeum
Copy link
Collaborator

fmeum commented Nov 29, 2024

What happens if you also specify --host_per_file_copt?

@meteorcloudy
Copy link
Member

It is working for Bazel itself:

bazel/.bazelrc

Lines 53 to 58 in f5abf15

build:linux --per_file_copt=external/.*@-w
build:linux --host_per_file_copt=external/.*@-w
build:macos --per_file_copt=external/.*@-w
build:macos --host_per_file_copt=external/.*@-w
build:windows --per_file_copt=external/.*@/w
build:windows --host_per_file_copt=external/.*@/w

@mering Does Fabian's suggestion work? Can you provide a minimal repo?

@mering
Copy link
Author

mering commented Nov 29, 2024

@meteorcloudy thanks for confirming that the syntax didn't change.

@fmeum Indeed, this reduces the number of failures significantly.

From a brief look over the remaining issues, it seems that most (or all?) remaining issues are related to rules_foreign_cc. I will try to create a small reproduction example.

@mering
Copy link
Author

mering commented Nov 29, 2024

It seems to error out already for compiling the make tool for rules_foreign_cc:

ERROR: /home/builder/.cache/bazel/_bazel_builder/395eea75460def8a11dd35795d615210/external/rules_foreign_cc~/toolchains/private/BUILD.bazel:23:10: BootstrapGNUMake external/rules_foreign_cc~/toolchains/private/make [for tool] failed: (Exit 1): bash failed: error executing BootstrapGNUMake command (from target @@rules_foreign_cc~//toolchains/private:make_tool) 
  (cd /home/builder/.cache/bazel/_bazel_builder/395eea75460def8a11dd35795d615210/execroot/_main && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
  /bin/bash -c bazel-out/k8-opt-exec-ST-812c6e1a5506/bin/external/rules_foreign_cc~/toolchains/private/make_tool_foreign_cc/wrapper_build_script.sh)
# Configuration: 3c2b98fc521fcd3d8b359a35f5ff3b629dc724a5e2283dad7bcafed8e1f074d8
# Execution platform: //bazel:linux_x86_64
rules_foreign_cc: Build failed!
rules_foreign_cc: Keeping temp build directory and dependencies directory for debug.
rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify --sandbox_debug Bazel command line flag.
rules_foreign_cc: Printing build logs:
_____ BEGIN BUILD LOGS _____
+ ZERO_AR_DATE=1
+ AR=/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/llvm-ar
+ ARFLAGS=
+ CC='/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/'
+ CFLAGS='-U_FORTIFY_SOURCE --target=x86_64-unknown-linux-gnu -U_FORTIFY_SOURCE -fstack-protector -fno-omit-frame-pointer -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -g0 -O2 -D_FORTIFY_SOURCE=1 -DNDEBUG -ffunction-sections -fdata-sections -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -fdebug-prefix-map=/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain_llvm/=__bazel_toolchain_llvm_repo__/ -Werror'
+ LD='/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/'
+ LDFLAGS='-Wl,-S --target=x86_64-unknown-linux-gnu -lm -no-canonical-prefixes -fuse-ld=lld -Wl,--build-id=md5 -Wl,--hash-style=gnu -Wl,-z,relro,-z,now -l:libc++.a -l:libc++abi.a -l:libunwind.a -lpthread -ldl -rtlib=compiler-rt -Wl,--gc-sections'
+ ./configure --without-guile --with-guile=no --disable-dependency-tracking --prefix=/b/f/w/bazel-out/k8-opt-exec-ST-812c6e1a5506/bin/external/rules_foreign_cc~/toolchains/private/make
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking whether make supports the include directive... no
checking for gcc... /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ accepts -g... yes
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ option to enable C11 features... unsupported
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ option to enable C99 features... unsupported
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ option to enable C89 features... unsupported
checking whether /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ understands -c and -o together... yes
checking whether the compiler is clang... yes
checking for compiler option needed when checking for declarations... -Werror=implicit-function-declaration
checking dependency style of /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/... none
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking for sys/param.h... yes
checking for stdbool.h... yes
checking for vfork.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking for gcc... (cached) /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/
checking whether the compiler supports GNU C... (cached) yes
checking whether /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ accepts -g... (cached) yes
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ option to enable C11 features... (cached) unsupported
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ option to enable C99 features... (cached) unsupported
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ option to enable C89 features... (cached) unsupported
checking whether /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ understands -c and -o together... (cached) yes
checking whether the compiler is clang... (cached) yes
checking for compiler option needed when checking for declarations... (cached) -Werror=implicit-function-declaration
checking dependency style of /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/... (cached) none
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking for clang++... no
checking whether the compiler supports GNU C++... no
checking whether g++ accepts -g... no
checking for g++ option to enable C++11 features... none needed
checking dependency style of g++... none
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to run the C preprocessor... /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for Minix Amsterdam compiler... no
checking for ar... /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/llvm-ar
checking for ranlib... no
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ option to enable large file support... none needed
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for eaccess... yes
checking for /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ options needed to detect all undeclared functions... none needed
checking host CPU and C ABI... x86_64
checking for C compiler option to allow warnings... -Wno-error
checking for alloca as a compiler built-in... yes
checking for getloadavg... yes
checking for sys/loadavg.h... no
checking whether getloadavg is declared... yes
checking if system libc has working GNU glob... yes
checking whether system uses MSDOS-style paths... no
checking for bool, true, false... no
checking for ranlib... :
checking how to run the C preprocessor... /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/ -E
checking for ar... /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/llvm-ar
checking for perl... perl
checking whether byte ordering is bigendian... no
checking for a sed that does not truncate output... /bin/sed
checking whether NLS is requested... yes
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking for ld used by /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/... /b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/
checking if the linker (/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/) is GNU ld... no
checking for shared library run path origin... done
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyCurrent... no
checking for GNU gettext in libc... yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking for library containing strerror... no
checking for library containing getpwnam... none required
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking whether stat file-mode macros are broken... no
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for locale.h... yes
checking for unistd.h... (cached) yes
checking for limits.h... yes
checking for memory.h... yes
checking for sys/param.h... (cached) yes
checking for sys/resource.h... yes
checking for sys/timeb.h... yes
checking for sys/time.h... yes
checking for sys/select.h... yes
checking for sys/file.h... yes
checking for fcntl.h... yes
checking for spawn.h... yes
checking for an ANSI C-conforming const... no
checking for uid_t in sys/types.h... yes
checking for pid_t... yes
checking for off_t... yes
checking for size_t... (cached) yes
checking for ssize_t... yes
checking for unsigned long long int... yes
checking for long long int... yes
checking for intmax_t... yes
checking for uintmax_t... yes
checking for sig_atomic_t... yes
checking for nanoseconds field of struct stat... st_mtim.tv_nsec
checking whether to use high resolution file timestamps... no
checking for standard gettimeofday... yes
checking for strtoll... no
checking for strdup... no
checking for strndup... no
checking for stpcpy... no
checking for memrchr... yes
checking for mempcpy... no
checking for umask... yes
checking for mkstemp... yes
checking for mktemp... yes
checking for fdopen... yes
checking for dup... yes
checking for dup2... yes
checking for getcwd... yes
checking for realpath... yes
checking for sigsetmask... yes
checking for sigaction... yes
checking for getgroups... yes
checking for seteuid... yes
checking for setegid... yes
checking for setlinebuf... yes
checking for setreuid... yes
checking for setregid... yes
checking for mkfifo... yes
checking for getrlimit... yes
checking for setrlimit... yes
checking for setvbuf... yes
checking for pipe... yes
checking for strerror... no
checking for strsignal... yes
checking for lstat... yes
checking for readlink... yes
checking for atexit... yes
checking for isatty... yes
checking for ttyname... yes
checking for pselect... yes
checking for posix_spawn... yes
checking for posix_spawnattr_setsigmask... yes
checking whether bsd_signal is declared... no
checking for fork... yes
checking for vfork... no
checking for working fork... yes
checking for strcasecmp... no
checking for strncasecmp... no
checking for strcmpi... no
checking for strncmpi... no
checking for stricmp... no
checking for strnicmp... no
checking for working strcoll... yes
checking whether closedir returns void... yes
checking for struct dirent.d_type... yes
checking for pkg-config... no
checking whether sys_siglist is declared... yes
checking whether _sys_siglist is declared... yes
checking whether __sys_siglist is declared... no
checking for sys/wait.h... yes
checking for waitpid... yes
checking for wait3... yes
checking for union wait... no
checking for SA_RESTART... yes
checking whether dlopen is declared... yes
checking whether dlsym is declared... yes
checking whether dlerror is declared... yes
checking for library containing dlopen... none required
checking if the linker accepts -Wl,--export-dynamic... yes
checking for posix_spawn that fails synchronously... yes
checking for location of SCCS get command... get
checking if malloc debugging is wanted... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating build.cfg
config.status: creating tests/config-flags.pm
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating doc/Makefile
config.status: creating po/Makefile.in
config.status: creating src/config.h
config.status: executing depfiles commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
+ cat build.cfg
# Configuration for building GNU Make in the absence of any 'make' program.
# build.cfg.  Generated from build.cfg.in by configure.

# Copyright (C) 1993-2023 Free Software Foundation, Inc.
# This file is part of GNU Make.
#
# GNU Make is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program.  If not, see <https://www.gnu.org/licenses/>.

# See Makefile.in for comments describing these variables.

top_srcdir='.'

prefix='/b/f/w/bazel-out/k8-opt-exec-ST-812c6e1a5506/bin/external/rules_foreign_cc~/toolchains/private/make'
exec_prefix=`eval echo ${prefix}`

CC='/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/cc_wrapper.sh --sysroot=/b/f/w/external/ai_intrinsic_sdks~~non_module_deps_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/'
AR='/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain/bin/llvm-ar'
CFLAGS='-U_FORTIFY_SOURCE --target=x86_64-unknown-linux-gnu -U_FORTIFY_SOURCE -fstack-protector -fno-omit-frame-pointer -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -g0 -O2 -D_FORTIFY_SOURCE=1 -DNDEBUG -ffunction-sections -fdata-sections -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -fdebug-prefix-map=/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain_llvm/=__bazel_toolchain_llvm_repo__/ -Werror '
CPPFLAGS=''
DEFS='-DHAVE_CONFIG_H'
ARFLAGS='cr'
LDFLAGS='-Wl,--export-dynamic -Wl,-S --target=x86_64-unknown-linux-gnu -lm -no-canonical-prefixes -fuse-ld=lld -Wl,--build-id=md5 -Wl,--hash-style=gnu -Wl,-z,relro,-z,now -l:libc++.a -l:libc++abi.a -l:libunwind.a -lpthread -ldl -rtlib=compiler-rt -Wl,--gc-sections'
ALLOCA=''
LOADLIBES='  '
REMOTE='stub'
OBJEXT='o'
EXEEXT=''
+ ./build.sh
config.status: creating ./lib/alloca.h__
compiling lib/concat-filename.c...
In file included from ./lib/concat-filename.c:19:
In file included from ./src/config.h:1331:
./src/../src/mkcustom.h:52:5: error: incompatible redeclaration of library function 'strcasecmp' [-Werror,-Wincompatible-library-redeclaration]
   52 | int strcasecmp (const char *s1, const char *s2);
      |     ^
./src/../src/mkcustom.h:52:5: note: 'strcasecmp' is a builtin with type 'int (const char *, const char *)'
./src/../src/mkcustom.h:56:5: error: incompatible redeclaration of library function 'strncasecmp' [-Werror,-Wincompatible-library-redeclaration]
   56 | int strncasecmp (const char *s1, const char *s2, size_t n);
      |     ^
./src/../src/mkcustom.h:56:5: note: 'strncasecmp' is a builtin with type 'int (const char *, const char *, unsigned long)'
./src/../src/mkcustom.h:60:7: error: incompatible redeclaration of library function 'mempcpy' [-Werror,-Wincompatible-library-redeclaration]
   60 | void *mempcpy (void *dest, const void *src, size_t n);
      |       ^
./src/../src/mkcustom.h:60:7: note: 'mempcpy' is a builtin with type 'void *(void *, const void *, unsigned long)'
./src/../src/mkcustom.h:64:7: error: incompatible redeclaration of library function 'stpcpy' [-Werror,-Wincompatible-library-redeclaration]
   64 | char *stpcpy (char *dest, const char *src);
      |       ^
./src/../src/mkcustom.h:64:7: note: 'stpcpy' is a builtin with type 'char *(char *, const char *)'
4 errors generated.
Compilation failed.
_____ END BUILD LOGS _____
rules_foreign_cc: Build wrapper script location: bazel-out/k8-opt-exec-ST-812c6e1a5506/bin/external/rules_foreign_cc~/toolchains/private/make_tool_foreign_cc/wrapper_build_script.sh
rules_foreign_cc: Build script location: bazel-out/k8-opt-exec-ST-812c6e1a5506/bin/external/rules_foreign_cc~/toolchains/private/make_tool_foreign_cc/build_script.sh
rules_foreign_cc: Build log location: bazel-out/k8-opt-exec-ST-812c6e1a5506/bin/external/rules_foreign_cc~/toolchains/private/make_tool_foreign_cc/BootstrapGNUMake.lo

So this seems to pass the normal copt (-Werror) but not the per_file_copt:

CFLAGS='-U_FORTIFY_SOURCE --target=x86_64-unknown-linux-gnu -U_FORTIFY_SOURCE -fstack-protector -fno-omit-frame-pointer -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -g0 -O2 -D_FORTIFY_SOURCE=1 -DNDEBUG -ffunction-sections -fdata-sections -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -fdebug-prefix-map=/b/f/w/external/toolchains_llvm~~llvm~llvm_toolchain_llvm/=__bazel_toolchain_llvm_repo__/ -Werror'

Is there a way to pass a copt to all rules_foreign_cc targets?

@meteorcloudy
Copy link
Member

Is there a way to pass a copt to all rules_foreign_cc targets?

I guess not? But it's better to check with the rules_foreign_cc maintainer.

@mering
Copy link
Author

mering commented Nov 29, 2024

What would be the best way for rules_foreign_cc to implement per_file_copt?

@keith
Copy link
Member

keith commented Nov 29, 2024

I don't think it's possible because the values of per_file_copt are not exposed to starlark. I workaround this by duplicating the options onto any rules_foreign_cc targets (which then applies to all files not just a single file) unfortunately.

@mering
Copy link
Author

mering commented Nov 29, 2024

I don't think it's possible because the values of per_file_copt are not exposed to starlark. I workaround this by duplicating the options onto any rules_foreign_cc targets (which then applies to all files not just a single file) unfortunately.

@keith Thanks for sharing your insights. Unfortunately, some of the rules_foreign_cc targets come in as transitive dependencies where we don't have control over in the root module. Do you have any recommendations on how one could set the options in this case?

@keith
Copy link
Member

keith commented Nov 29, 2024

practically speaking you'd have to use patches somehow. long term i agree that bazel should expose this, but unfortunately that would likely also depend on starlark having a regex API 🙃

@mering
Copy link
Author

mering commented Dec 2, 2024

@keith Do you know if there is a way to pass copt for rules_foreign_cc tools (make, pkgconfig) which are also failing (bazel-contrib/rules_foreign_cc#1333)?

@keith
Copy link
Member

keith commented Dec 2, 2024

im going to dedup with #14764 and comment on those upstream issues

@keith keith closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: bug untriaged
Projects
None yet
Development

No branches or pull requests

7 participants