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

llvm-ar error on MacOS #237

Closed
garymm opened this issue Oct 30, 2023 · 6 comments
Closed

llvm-ar error on MacOS #237

garymm opened this issue Oct 30, 2023 · 6 comments

Comments

@garymm
Copy link
Contributor

garymm commented Oct 30, 2023

Not sure if this is caused by upgrading to MacOS 14 (Sonoma), but whenever I try to build a library I get this:
In the root of this repo:

cd tests
bazel build //:stdlib

output:

ERROR: /Users/garymm/src/grailbio/bazel-toolchain/tests/BUILD.bazel:19:11: Linking libstdlib.a failed: (Exit 1): llvm-ar failed: error executing command (from target //:stdlib) external/llvm_toolchain/bin/llvm-ar @bazel-out/darwin_arm64-fastbuild/bin/libstdlib.a-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/llvm_toolchain/bin/llvm-ar: error: an archive name must be specified

My system:
MacOS 14.0 (23A344)
ARM64 (apple silicon)
XCode command-line tools version 15.0.0

@purkhusid
Copy link

Hitting the same issue on our MacOS developer laptops:

failed: error executing CppArchive command (from target @zlib//:zlib) 
  (cd /private/var/tmp/_bazel_fanneysig/324559263f76ffc3bd97662b513c34ce/sandbox/darwin-sandbox/3152/execroot/monorepo && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
    ZERO_AR_DATE=1 \
  external/llvm_toolchain/bin/llvm-ar @bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/libzlib.a-2.params)
# Configuration: 0d2a7eb20d2f7e85969e3603a64bae96333b7b713cae26f6dd2ffe84cc7b408b
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/llvm_toolchain/bin/llvm-ar: error: only one operation may be specified
OVERVIEW: LLVM Archiver

USAGE: llvm-ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [files]
       llvm-ar -M [<mri-script]

OPTIONS:
  --format              - archive format to create
    =default            -   default
    =gnu                -   gnu
    =darwin             -   darwin
    =bsd                -   bsd
    =bigarchive         -   big archive (AIX OS)
  --plugin=<string>     - ignored for compatibility
  -h --help             - display this help and exit
  --output              - the directory to extract archive members to
  --rsp-quoting         - quoting style for response files
    =posix              -   posix
    =windows            -   windows
  --thin                - create a thin archive
  --version             - print the version and exit
  -X{32|64|32_64|any}   - object mode (only for AIX OS)
  @<file>               - read options from <file>

OPERATIONS:
  d - delete [files] from the archive
  m - move [files] in the archive
  p - print contents of [files] found in the archive
  q - quick append [files] to the archive
  r - replace or insert [files] into the archive
  s - act as ranlib
  t - display list of files in archive
  x - extract [files] from the archive

MODIFIERS:
  [a] - put [files] after [relpos]
  [b] - put [files] before [relpos] (same as [i])
  [c] - do not warn if archive had to be created
  [D] - use zero for timestamps and uids/gids (default)
  [h] - display this help and exit
  [i] - put [files] before [relpos] (same as [b])
  [l] - ignored for compatibility
  [L] - add archive's contents
  [N] - use instance [count] of name
  [o] - preserve original dates
  [O] - display member offsets
  [P] - use full names when matching (implied for thin archives)
  [s] - create an archive index (cf. ranlib)
  [S] - do not build a symbol table
  [T] - deprecated, use --thin instead
  [u] - update only [files] newer than archive contents
  [U] - use actual timestamps and uids/gids
  [v] - be verbose about actions taken
  [V] - display the version and exit
ERROR: /Users/fanneysig/work/monorepo/src/dotnet/ingestion/deploy/api/BUILD.bazel:5:13 Writing: bazel-out/darwin_arm64-fastbuild/bin/src/dotnet/ingestion/deploy/api/image_app_layer.tar failed: (Exit 1): llvm-ar failed: error executing CppArchive command (from target @zlib//:zlib) 
  (cd /private/var/tmp/_bazel_fanneysig/324559263f76ffc3bd97662b513c34ce/sandbox/darwin-sandbox/3152/execroot/monorepo && \
  exec env - \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
    ZERO_AR_DATE=1 \
  external/llvm_toolchain/bin/llvm-ar @bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/libzlib.a-2.params)

Params file:

-static
-o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/libzlib.a
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/adler32.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/compress.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/crc32.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/deflate.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/gzclose.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/gzlib.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/gzread.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/gzwrite.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/infback.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/inffast.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/inflate.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/inftrees.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/trees.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/uncompr.o
bazel-out/darwin_arm64-opt-exec-ST-c54f45c8267f/bin/external/zlib/_objs/zlib/zutil.o

@purkhusid
Copy link

Actually, I think these two are different issues. WIll open a new ticker for my issue.

@garymm garymm changed the title llvm-ar error on MacOS (maybe Sonoma specific?) llvm-ar error on MacOS Nov 3, 2023
@garymm
Copy link
Contributor Author

garymm commented Nov 3, 2023

Turns out this was fixed by setting this in bazelrc:

build --features=-libtool

Should probably be in README.md? I think it'll be needed until #229 is merged.
I can try to edit the README later.

@siddharthab
Copy link
Contributor

It is mentioned in https://github.com/grailbio/bazel-toolchain/blob/7500623e00c62cd5e6f07b8569a3598daa05cf8c/.github/workflows/release_notes_template.txt#L70, but somehow that last line is being cut off from the release notes. Maybe because I manually edited the release notes once. I will manually add that line back in.

@aran
Copy link

aran commented Feb 20, 2024

Using macOS 14.2.1 (23C71), I see llvm-ar errors when using bzlmod to build go code that uses protobufs regardless of build --features=-libtool.

A small repro repo is here: https://github.com/aran/bzlmod-llvm-go-macos with an error paste here: https://github.com/aran/bzlmod-llvm-go-macos/blob/main/error.md

Not sure if I should open a new issue, flag it to a different project, or try something else to debug.

@aran
Copy link

aran commented Feb 20, 2024

I should mention, I have seen both error: an archive name must be specified and error: only one operation may be specified as I experimented with this and I can't figure out exactly what makes the difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants