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

Tutorial failed on mac (with bazel version v4.2.2), error: libtool command fail #14578

Closed
old-bear opened this issue Jan 14, 2022 · 8 comments
Closed
Labels
team-Documentation Documentation improvements that cannot be directly linked to other team labels untriaged

Comments

@old-bear
Copy link

old-bear commented Jan 14, 2022

Description of the problem / feature request:

The tutorial STAGE-2 on the official website failed on mac-os 10.12.6:

[^_^ 14:10 ~/Playground/bazel-examples/cpp-tutorial/stage2] bazel build //main:hello-world
INFO: Analyzed target //main:hello-world (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /Users/Bear/Playground/bazel-examples/cpp-tutorial/stage2/main/BUILD:3:11: Linking main/libhello-greet.a failed: (Exit 1): libtool failed: error executing command /usr/bin/libtool @bazel-out/darwin-fastbuild/bin/main/libhello-greet.a-2.params

Use --sandbox_debug to see verbose messages from the sandbox
error: /Library/Developer/CommandLineTools/usr/bin/libtool: no output file specified (specify with -o output)
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table ] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
Target //main:hello-world failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.174s, Critical Path: 0.05s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully

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

Just follow the tutorial of stage2

What operating system are you running Bazel on?

mac10.12.6, with xcode-tools:
[^_^ 14:25 ~/Downloads] xcode-select -v
xcode-select version 2347.

What's the output of bazel info release?

release 4.2.2

Have you found anything relevant by searching the web?

I've found some related answers before, but they are all marked as solved on former bazel version. Also I tried to debug this problem, it seems mac version libtool needs a -o option while gnu libtool need not. Does it mean I should replace libtool using glibtool?

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

Replace this line with your answer.

@keith
Copy link
Member

keith commented Jan 14, 2022

Your actual Xcode version isn't included in this report, you can fetch it with xcodebuild -version. It's likely a bit behind and potentially unsupported because of it. I would recommend updating Xcode as much as you can, or your OS to update it further. Worst case you could theoretically replace the libtool usage with the one from LLVM/main, but that isn't configurable today.

@old-bear
Copy link
Author

@keith Thanks, when I run xcodebuild -version I get

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Does it mean I have to install the whole Xcode App? which is kind of large for my disk space now ..

@sventiffe sventiffe added team-Documentation Documentation improvements that cannot be directly linked to other team labels untriaged labels Jan 14, 2022
@keith
Copy link
Member

keith commented Jan 14, 2022

Ah no, not having Xcode is theoretically fine. But assuming you're up to date in the system software update (so the command line tools are updated) you'll either have to update your major OS version to open yourself up to new versions of the command line tools, or replace libtool as I mentioned above

@old-bear
Copy link
Author

old-bear commented Jan 17, 2022

Thanks for the reply. Unfortunately I found the version of my xcode command line tools is 9.2, which is already the highest under maxos 10.12. I guess I have to upgrade my macos now. Could you tell me what's the lowest required version for the latest bazel?

@sventiffe
Copy link
Contributor

We're running our tests on 11.6.1

@philwo
Copy link
Member

philwo commented Jan 17, 2022

@old-bear We recommend upgrading to the latest available macOS and Xcode version that runs on your Mac, because older macOS versions do not receive security updates from Apple.

Unfortunately we can't test Bazel on older macOS or Xcode versions, so we're only testing / supporting relatively recent versions (currently macOS 11.6.1 and Xcode 13.0, we'll probably upgrade to macOS 12 after 5.0 is released).

We try to avoid breaking Bazel on older versions of macOS / Xcode, but as we can't test it ourselves and don't have the bandwidth to actively investigate these kind of problems, we rely on users to report and provide patches to restore compatibility.

@feuyeux
Copy link

feuyeux commented Mar 11, 2024

brew uninstall libtool
ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool /usr/local/opt/libtool/libexec/gnubin/libtool

@ShapeLayer
Copy link

brew uninstall libtool
ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool /usr/local/opt/libtool/libexec/gnubin/libtool

If libtool installed with homebrew is used for other purposes and cannot be removed, the path can be defined to use Xcode toolchain included libtool using .bazelrc

❯ cat ~/.bazelrc  #or cat ./.bazelrc
build --action_env=LIBTOOL=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
test --action_env=LIBTOOL=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Documentation Documentation improvements that cannot be directly linked to other team labels untriaged
Projects
None yet
Development

No branches or pull requests

6 participants