rules_foreign_cc
rules_foreign_cc copied to clipboard
make_tool fails on Mac
Running
bazel build //toolchains:make_tool
gives the error
ERROR: /Users/arvid/code/rules_foreign_cc/toolchains/BUILD.bazel:101:10: BootstrapGNUMake toolchains/make failed: (Exit 1): bash failed: error executing command /bin/bash -c bazel-out/darwin_arm64-fastbuild/bin/toolchains/make_tool_foreign_cc/wrapper_build_script.sh
Use --sandbox_debug to see verbose messages from the sandbox
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 _____
+ AR=/usr/bin/libtool
+ ARFLAGS='-static -s -o'
+ CC=/private/var/tmp/_bazel_arvid/85010f56e01f735203a9fe937d668c53/sandbox/darwin-sandbox/8/execroot/rules_foreign_cc/external/local_config_cc/cc_wrapper.sh
+ CFLAGS='-U_FORTIFY_SOURCE -fstack-p
..
.. (many lines)
..
compiling lib/exitfail.c...
compiling lib/fd-hook.c...
compiling lib/findprog-in.c...
./lib/findprog-in.c:137:25: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (eaccess (progpathname, X_OK) == 0)
^
./lib/findprog-in.c:137:25: note: did you mean 'access'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:431:6: note: 'access' declared here
int access(const char *, int);
^
./lib/findprog-in.c:211:21: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (eaccess (progpathname, X_OK) == 0)
^
2 errors generated.
_____ END BUILD LOGS _____
rules_foreign_cc: Build wrapper script location: bazel-out/darwin_arm64-fastbuild/bin/toolchains/make_tool_foreign_cc/wrapper_build_script.sh
rules_foreign_cc: Build script location: bazel-out/darwin_arm64-fastbuild/bin/toolchains/make_tool_foreign_cc/build_script.sh
rules_foreign_cc: Build log location: bazel-out/darwin_arm64-fastbuild/bin/toolchains/make_tool_foreign_cc/BootstrapGNUMake.log
Target //toolchains:make_tool failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 15.214s, Critical Path: 14.87s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
I'm running on Mac (arm64) using bazel 4.2.2. Has anyone seen this issue before, or know how to fix it?
If there is no immediate fix, I would be interested in using configure_make
without having to build make_tool
(for example, by using the make
already installed on my system, or using ninja
). How would I do this?
I'm looking at the exact same error on Mac OS Big Sur 11.2.3
using (bazel
version 4.1.0-homebrew
, rules_foregin_cc
version 0.7.1
)
What I'd like to build using the rule configure_make
, I had been able to build within the Bazel sandbox (by misusing the patch commands of http_archive
) earlier. So, I'm pretty sure my Bazel sandbox has access to everything needed to build the package. I was wondering if there is any way to avoid building https://github.com/coreutils/gnulib/ (which contains the failing lib/findprog-in.c
) during the bootstrap of rules_foreign_cc and somehow ask it to use the tools available already within the sandbox?
0.6.0 does not seem to have this issue.
Seeing the same issue on
- bazel
6.0.0-pre.20220127.1
- rules_rust
f54068e889417d7d90fc0d171b8c44d4e1697785
- macos
12.2.1
- xcode command line tools (not full-blown xcode)
- Intel mac
If anyone finds a workaround or solution, please post here.
For some reason rule_foreign_cc started to pass -undefined dynamic_lookup to the configure. That is wrong and cannot possibly work. Workaround for 0.7.1:
diff --git a/WORKSPACE b/WORKSPACE
index be02081d07..e5f3d04126 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -41,6 +41,8 @@ maybe(
sha256 = "bcd0c5f46a49b85b384906daae41d277b3dc0ff27c7c752cc51e43048a58ec83",
strip_prefix = "rules_foreign_cc-0.7.1",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.7.1.tar.gz",
+ patch_args = ["-p1"],
+ patches = ["//third_party/rules_foreign_cc:macos-ldflags.patch"],
)
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
diff --git a/third_party/rules_foreign_cc/BUILD b/third_party/rules_foreign_cc/BUILD
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/third_party/rules_foreign_cc/macos-ldflags.patch b/third_party/rules_foreign_cc/macos-ldflags.patch
new file mode 100644
index 0000000000..bc1e3b7c76
--- /dev/null
+++ b/third_party/rules_foreign_cc/macos-ldflags.patch
@@ -0,0 +1,14 @@
+diff --git a/foreign_cc/built_tools/make_build.bzl b/foreign_cc/built_tools/make_build.bzl
+index 1d0ad29..1f85fd2 100644
+--- a/foreign_cc/built_tools/make_build.bzl
++++ b/foreign_cc/built_tools/make_build.bzl
+@@ -71,6 +71,9 @@ def _make_tool_impl(ctx):
+ if absolute_ar == "libtool" or absolute_ar.endswith("/libtool"):
+ arflags.append("-o")
+
++ if os_name(ctx) == "macos":
++ non_sysroot_ldflags += ["-undefined", "error"]
++
+ env.update({
+ "AR": absolute_ar,
+ "ARFLAGS": _join_flags_list(ctx.workspace_name, arflags),
@graywolf-at-work do you have any insights as to why this isn't failing in CI? Is this specific to Apple silicon macOS as that configuration isn't tested by CI due to lack of availability of any Apple Silicon machine in bazel's CI.
I don't have m1, nor I am an expert on this project or bazel, but I would guess it's a combination of https://github.com/bazelbuild/rules_foreign_cc/blob/main/toolchains/BUILD.bazel#L104 and https://github.com/bazelbuild/rules_foreign_cc/blob/main/.bazelci/config.yaml#L18 . In other words, it's not being built as part of the CI. So it does not fail.
For some reason rule_foreign_cc started to pass -undefined dynamic_lookup to the configure. That is wrong and cannot possibly work. Workaround for 0.7.1:
diff --git a/WORKSPACE b/WORKSPACE index be02081d07..e5f3d04126 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -41,6 +41,8 @@ maybe( sha256 = "bcd0c5f46a49b85b384906daae41d277b3dc0ff27c7c752cc51e43048a58ec83", strip_prefix = "rules_foreign_cc-0.7.1", url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.7.1.tar.gz", + patch_args = ["-p1"], + patches = ["//third_party/rules_foreign_cc:macos-ldflags.patch"], ) load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") rules_foreign_cc_dependencies() diff --git a/third_party/rules_foreign_cc/BUILD b/third_party/rules_foreign_cc/BUILD new file mode 100644 index 0000000000..e69de29bb2 diff --git a/third_party/rules_foreign_cc/macos-ldflags.patch b/third_party/rules_foreign_cc/macos-ldflags.patch new file mode 100644 index 0000000000..bc1e3b7c76 --- /dev/null +++ b/third_party/rules_foreign_cc/macos-ldflags.patch @@ -0,0 +1,14 @@ +diff --git a/foreign_cc/built_tools/make_build.bzl b/foreign_cc/built_tools/make_build.bzl +index 1d0ad29..1f85fd2 100644 +--- a/foreign_cc/built_tools/make_build.bzl ++++ b/foreign_cc/built_tools/make_build.bzl +@@ -71,6 +71,9 @@ def _make_tool_impl(ctx): + if absolute_ar == "libtool" or absolute_ar.endswith("/libtool"): + arflags.append("-o") + ++ if os_name(ctx) == "macos": ++ non_sysroot_ldflags += ["-undefined", "error"] ++ + env.update({ + "AR": absolute_ar, + "ARFLAGS": _join_flags_list(ctx.workspace_name, arflags),
Any update for that? I still get same error messages after patch applied
Also seeing this on an up to date M1 Pro.
As far as I know, none of the regular contributors or maintainers have access to an M1 mac and so we're reliant on contributions from the wider community to fix this up.
PR's very welcome to fix any M1 specific issues.
Happy to help fix things! Thanks for being so responsive on these issues. Would you be able to help me understand what's going wrong here so we can fix it together?
❯ bazel build @com_github_capnproto_capnproto//...
(13:40:58) INFO: Current date is 2022-04-19
(13:40:58) INFO: Analyzed 2 targets (64 packages loaded, 2092 targets configured).
(13:40:58) INFO: Found 2 targets...
(13:41:16) ERROR: /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/external/rules_foreign_cc/toolchains/BUILD.bazel:130:10: BootstrapGNUMake external/rules_foreign_cc/toolchains/make failed: (Exit 1): bash failed: error executing command /bin/bash -c bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/wrapper_build_script.sh
Use --sandbox_debug to see verbose messages from the sandbox
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 _____
+ AR=/usr/bin/libtool
+ ARFLAGS='-static -s -o'
+ CC=/private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh
+ CFLAGS='-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -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'
+ LD=/private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh
+ LDFLAGS='-undefined dynamic_lookup -headerpad_max_install_names -lc++ -lm'
+ ./configure --without-guile --with-guile=no --disable-dependency-tracking --prefix=/private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make
checking for a BSD-compatible install... /Users/thomas/.nix-profile/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /Users/thomas/.nix-profile/bin/mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh
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 we are using the GNU C compiler... yes
checking whether /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh accepts -g... yes
checking for /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh option to accept ISO C89... none needed
checking whether /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh understands -c and -o together... yes
checking dependency style of /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh... none
checking how to run the C preprocessor... /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking for gcc... (cached) /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh
checking whether we are using the GNU C compiler... (cached) yes
checking whether /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh accepts -g... (cached) yes
checking for /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh option to accept ISO C89... (cached) none needed
checking whether /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh understands -c and -o together... (cached) yes
checking dependency style of /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh... (cached) none
checking for Minix Amsterdam compiler... no
checking for ar... /usr/bin/libtool
checking for ranlib... ranlib
checking build system type... arm-apple-darwin21.4.0
checking host system type... arm-apple-darwin21.4.0
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for _set_invalid_parameter_handler... yes
checking for fcntl... yes
checking for symlink... yes
checking for getdtablesize... yes
checking for getprogname... yes
checking for getexecname... yes
checking for sys/socket.h... yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for limits.h... yes
checking for wchar.h... yes
checking for stdint.h... (cached) yes
checking whether // is distinct from /... no
checking whether the preprocessor supports include_next... yes
checking whether system header files limit the line length... no
checking for complete errno.h... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... no
checking for working fcntl.h... yes
checking for pid_t... yes
checking for mode_t... yes
checking for eaccess... yes
checking whether getdtablesize is declared... yes
checking host CPU and C ABI... arm64
checking whether limits.h has LLONG_MAX, WORD_BIT, ULLONG_WIDTH etc.... no
checking whether malloc, realloc, calloc are POSIX compliant... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for wchar_t... yes
checking for wint_t... yes
checking whether wint_t is too small... no
checking whether stdint.h conforms to C99... yes
checking whether stdint.h predates C++11... no
checking whether stdint.h has UINTMAX_WIDTH etc.... no
checking for C/C++ restrict keyword... __restrict
checking whether strerror(0) succeeds... no
checking for alloca as a compiler built-in... yes
checking whether // is distinct from /... (cached) no
checking whether dup2 works... yes
checking for error_at_line... no
checking whether fcntl handles F_DUPFD correctly... yes
checking whether fcntl understands F_DUPFD_CLOEXEC... yes
checking whether getdtablesize works... yes
checking for getloadavg... yes
checking sys/loadavg.h usability... no
checking sys/loadavg.h presence... no
checking for sys/loadavg.h... no
checking whether getloadavg is declared... yes
checking whether program_invocation_name is declared... no
checking whether program_invocation_short_name is declared... no
checking whether __argv is declared... no
checking whether __progname is defined in default libraries... yes
checking if system libc has GNU glob... no
checking for ssize_t... yes
checking for good max_align_t... yes
checking whether NULL can be used in arbitrary expressions... yes
checking which flavor of printf attribute matches inttypes macros... system
checking for stpcpy... yes
checking for ranlib... (cached) ranlib
checking how to run the C preprocessor... /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh -E
checking for ar... /usr/bin/libtool
checking for perl... perl
checking for library containing strerror... none required
checking whether byte ordering is bigendian... no
checking for a sed that does not truncate output... /usr/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 /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh... /private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh
checking if the linker (/private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh) is GNU ld... no
checking for shared library run path origin... done
checking for CFPreferencesCopyAppValue... yes
checking for CFLocaleCopyCurrent... yes
checking for GNU gettext in libc... no
checking for iconv... yes
checking for working iconv... no
checking for GNU gettext in libintl... no
checking whether to use NLS... no
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for library containing getpwnam... none required
checking for ANSI C header files... (cached) yes
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 whether time.h and sys/time.h may both be included... yes
checking for stdlib.h... (cached) yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for unistd.h... (cached) yes
checking for limits.h... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for string.h... (cached) yes
checking for memory.h... (cached) yes
checking for sys/param.h... (cached) yes
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/timeb.h usability... yes
checking sys/timeb.h presence... yes
checking for sys/timeb.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking spawn.h usability... yes
checking spawn.h presence... yes
checking for spawn.h... yes
checking for an ANSI C-conforming const... yes
checking return type of signal handlers... void
checking for uid_t in sys/types.h... yes
checking for pid_t... (cached) 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 uintmax_t... yes
checking for nanoseconds field of struct stat... st_mtimespec.tv_nsec
checking whether to use high resolution file timestamps... yes
checking for library containing clock_gettime... none required
checking whether system uses MSDOS-style paths... no
checking for standard gettimeofday... yes
checking for strdup... yes
checking for strndup... yes
checking for memrchr... yes
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 getrlimit... yes
checking for setrlimit... yes
checking for setvbuf... yes
checking for pipe... yes
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... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for strcasecmp... yes
checking for strncasecmp... yes
checking for strcmpi... yes
checking for strncmpi... yes
checking for stricmp... yes
checking for strnicmp... yes
checking for working strcoll... yes
checking whether closedir returns void... no
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... no
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... no
checking If the linker accepts -rdynamic... 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 Makefile
config.status: creating build.cfg
config.status: creating lib/Makefile
config.status: creating po/Makefile.in
config.status: creating doc/Makefile
config.status: creating tests/config-flags.pm
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-2020 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 <http://www.gnu.org/licenses/>.
# See Makefile.in for comments describing these variables.
top_srcdir='.'
prefix='/private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make'
exec_prefix=`eval echo ${prefix}`
CC='/private/var/tmp/_bazel_thomas/796dd52d4d981101108548a9446ddca6/sandbox/darwin-sandbox/971/execroot/kraken/external/local_config_cc/cc_wrapper.sh'
AR='/usr/bin/libtool'
CFLAGS='-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -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 '
CPPFLAGS=''
DEFS='-DHAVE_CONFIG_H'
ARFLAGS='-static -s -o'
LDFLAGS='-rdynamic -undefined dynamic_lookup -headerpad_max_install_names -lc++ -lm'
ALLOCA=''
LOADLIBES=' '
REMOTE='stub'
OBJEXT='o'
EXEEXT=''
+ ./build.sh
config.status: creating ./lib/alloca.h__
config.status: creating ./lib/fcntl.h__
config.status: creating ./lib/limits.h__
config.status: creating ./lib/fnmatch.h__
config.status: creating ./lib/glob.h__
config.status: creating ./lib/stdint.h__
config.status: creating ./lib/stdio.h__
config.status: creating ./lib/stdlib.h__
config.status: creating ./lib/string.h__
config.status: creating ./lib/sys/types.h__
config.status: creating ./lib/unistd.h__
compiling lib/concat-filename.c...
compiling lib/dirname-lgpl.c...
compiling lib/basename-lgpl.c...
compiling lib/stripslash.c...
compiling lib/exitfail.c...
compiling lib/fd-hook.c...
compiling lib/findprog-in.c...
./lib/findprog-in.c:137:25: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (eaccess (progpathname, X_OK) == 0)
^
./lib/findprog-in.c:137:25: note: did you mean 'access'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:431:6: note: 'access' declared here
int access(const char *, int);
^
./lib/findprog-in.c:211:21: error: implicit declaration of function 'eaccess' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (eaccess (progpathname, X_OK) == 0)
^
2 errors generated.
_____ END BUILD LOGS _____
rules_foreign_cc: Build wrapper script location: bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/wrapper_build_script.sh
rules_foreign_cc: Build script location: bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/build_script.sh
rules_foreign_cc: Build log location: bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/BootstrapGNUMake.log
(13:41:16) INFO: Elapsed time: 18.702s, Critical Path: 17.88s
(13:41:16) INFO: 6 processes: 6 internal.
(13:41:16) FAILED: Build did NOT complete successfully
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)
configure_make(
name = "capnp",
autoconf = True,
configure_in_place = True,
lib_source = ":all_srcs",
visibility = ["//visibility:public"],
)
It would appear that the call to configure is incorrectly finding a successful compile for the function eaccess
at configure time but at build time the symbol is not present. I wonder if the configure script is calling a x86_64 binary for m4 / aclocal. The check for eaccess is done in the file gnumake_src/m4/eaccess.m4
but its been a long time since I've had to read / edit a autotools build so that's about the limit of my current understanding of what is going on.
I see, that makes sense. I'm not too familiar with C toolchains, and the only thing I could really find was this:
https://osdn.net/projects/android-x86/scm/git/external-alsa-lib/commits/76d1aa0cd7635f903bb1d48bb9c18279d46ec624
Though as you mentioned, it looks like make
should already be checking for this here.
Is there anything I can do to help debug why this is happening?
Interestingly, the patch suggested by @graywolf-at-work seems to work!
diff -urN a/foreign_cc/built_tools/make_build.bzl b/foreign_cc/built_tools/make_build.bzl
--- a/foreign_cc/built_tools/make_build.bzl 1969-12-31 19:00:00.000000000 -0500
+++ b/foreign_cc/built_tools/make_build.bzl 2000-01-01 00:00:00.000000000 -0000
@@ -71,6 +71,9 @@ def _make_tool_impl(ctx):
if absolute_ar == "libtool" or absolute_ar.endswith("/libtool"):
arflags.append("-o")
+ if os_name(ctx) == "macos":
+ non_sysroot_ldflags += ["-undefined", "error"]
+
env.update({
"AR": absolute_ar,
"ARFLAGS": _join_flags_list(ctx.workspace_name, arflags),
❯ bazel build @rules_foreign_cc//toolchains:make_tool
(14:43:01) INFO: Current date is 2022-04-19
(14:43:01) INFO: Analyzed target @rules_foreign_cc//toolchains:make_tool (64 packages loaded, 776 targets configured).
(14:43:01) INFO: Found 1 target...
Target @rules_foreign_cc//toolchains:make_tool up-to-date:
bazel-bin/external/rules_foreign_cc/toolchains/make
(14:43:22) INFO: Elapsed time: 21.545s, Critical Path: 21.16s
(14:43:22) INFO: 3 processes: 2 internal, 1 darwin-sandbox.
(14:43:22) INFO: Build completed successfully, 3 total actions
As far as I know, none of the regular contributors or maintainers have access to an M1 mac and so we're reliant on contributions from the wider community to fix this up.
PR's very welcome to fix any M1 specific issues.
Out of curiosity, what leads you to the conclusion that this is a M1 specific issue? I've hit this bug on normal, non-arm macbook.
As far as I know, none of the regular contributors or maintainers have access to an M1 mac and so we're reliant on contributions from the wider community to fix this up. PR's very welcome to fix any M1 specific issues.
Out of curiosity, what leads you to the conclusion that this is a M1 specific issue? I've hit this bug on normal, non-arm macbook.
bazel CI is running tests on x86_64 macOS as part of the regular testing that is done. However I guess if you are also seeing it on x86_64 then this could be a OS or XCode version that is causing this issue then.
https://buildkite.com/bazel/rules-foreign-cc/builds/3998#c472be5b-2981-4038-b49f-f3ffc6e2ef4a - looking at CI output CI is on macOS 11.6.1 and XCode 13. I suspect its the 11.6.1 that is causing this difference in experience.
@philwo @Wyverald @meteorcloudy - we're potentially seeing specific breakages in builds here due to newer version of macOS behaving differently to what the test configuration is in CI. Given BigSur is now OS -2 are there any plans to update the CI runners to a newer version?
That sounds about right. I'm on macOS 12.3.1 (21E258).
Should we open a PR for this fix?
Should we open a PR for this fix?
Please do
@jsharpe Yes, upgrading the macOS versions to the latest version is on our todo list, it should happen soon.
@meteorcloudy Thanks Yun
As far as I know, none of the regular contributors or maintainers have access to an M1 mac and so we're reliant on contributions from the wider community to fix this up. PR's very welcome to fix any M1 specific issues.
Out of curiosity, what leads you to the conclusion that this is a M1 specific issue? I've hit this bug on normal, non-arm macbook.
From the PR just opened it seems that the examples aren't building as expected anymore with the built make toolchain. I've opened #895 to track this as we should definitely address this.
I think you might have overlook this message from me: https://github.com/bazelbuild/rules_foreign_cc/issues/859#issuecomment-1060396218 . I've already stated on Mar 7 that the CI passes because it's not build as part of the CI.
Hi, has this issue been fixed? I'm still seeing this on MacOS 13.5
Can confirm this is also an issue on MacOS 14.1 so reopening.
Note that I don't have an M1 Mac (Quad-Core Intel Core i5 instead) and this issue shows up
I am hitting this issue on M2-based Mac (Sonoma 14.1) while using rules_foreign_cc v0.10.1 which includes the patch suggested above
+ if os_name(ctx) == "macos":
+ non_sysroot_ldflags += ["-undefined", "error"]
Also tried to use locally installed make/cmake with
rules_foreign_cc_dependencies(
register_preinstalled_tools = True, # https://github.com/bazelbuild/rules_foreign_cc/issues/672
)
but it did not help.
Just to follow up on @gerilya 's discussion here , installing Xcode seems to have helped resolve this. There seems to be something different between the toolchains of Xcode
and just Xcode command line tools
install xcode does help to resolve this, and don't forget to clean the bazel cache.
This didn't help, @tangm @xocodergit any specific command to check version or path ?
xcode-select -p
/Applications/Xcode.app/Contents/Developer
clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin