abergmeier
abergmeier

Reputation: 14071

Cannot switch gcc version

On a Ubuntu 16.04.2 I am trying to compile code with a newer gcc.

So I did the following:

  1. in the workspace create a file tools/cpp/CROSSTOOL
  2. copy latest CROSSTOOL content from bazel repo into that
  3. in CROSSTOOL file, under identifier local_linux, change /usr/bin/gcc to /usr/bin/gcc-7
  4. Call bazel build //foo

When I output the commandline executed to build //foo:foo, it calls /usr/bin/gcc.

Can someone point out what I am doing wrong?

Upvotes: 2

Views: 461

Answers (1)

hlopko
hlopko

Reputation: 3268

You are probably using static crosstool that is only used for bootstrapping and some tests (and some other details). What bazel usually uses is tools/cpp/CROSSTOOL.tpl which is a template populated by tools/cpp/cc_configure.bzl. This is the script that inspects CC environment variable and if set, it uses that for gcc.

Of course you can use static crosstool, you just have to tell bazel about it using --crosstool_top=//some/crosstool flag. You can save it in a project local .bazelrc.

Upvotes: 1

Related Questions