Jsonnet: Add instructions for building with Clang

Created on 25 Aug 2017  路  4Comments  路  Source: google/jsonnet

The README currently says:

The GCC C++ (g++) compiler is required to build Jsonnet. Clang is also supported.

However, the only instructions are for building with g++:

Makefile

To build jsonnet with g++, run:


Perhaps it should also say:

To build with Clang, run:

make CXX=clang++ CC=clang

Is that sufficient? Any other vars that need to be set?


Also, there are instructions for building with Bazel, but it's non-obvious (without reading all the BUILD / *.bzl files) which compiler it will use by default, and if it's g++, how to switch to Clang instead.

documentation

All 4 comments

Note that on macOS, g++ and gcc are both actually Clang, which makes the statement that "G++ is required; Clang is also supported" mildly amusing:

$ uname
Darwin

$ g++ --version | grep Apple
Apple LLVM version 8.1.0 (clang-802.0.42)

$ clang++ --version | grep Apple
Apple LLVM version 8.1.0 (clang-802.0.42)

$ gcc --version | grep Apple
Apple LLVM version 8.1.0 (clang-802.0.42)

$ clang --version | grep Apple
Apple LLVM version 8.1.0 (clang-802.0.42)

I presume if Jsonnet works on macOS, Jsonnet doesn't actually _require_ G++ (and since Apple replaced GCC/G++ with Clang globally, it must be a drop-in replacement for all development on macOS), so are there any concerns with making GCC and Clang as comparable choices in the docs, rather than favoring GCC over Clang? Or, given that Clang development is moving faster than GCC, perhaps inverting the requirement makes more sense?

Is that sufficient? Any other vars that need to be set?

I believe that's enough. I often did that during development to have better error messages.

Is that sufficient? Any other vars that need to be set?

I believe that's enough. I often did that during development to have better error messages.

That seems like sufficient evidence to make Clang the default over G++ so that everyone gets better error messages!

Mind you, I should mention why I'm biased in favor of Clang: I used to work on LLVM. :-)

We can start with adding Clang to the instructions as a parallel option, and maybe migrate it to the default at some point in the future.

Feel free to fix. There is an outstanding PR to add cmake support as well. I'd like to pivot from Makefile to that, because it makes it easier to have a visual studio build.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukasheinrich picture lukasheinrich  路  7Comments

ant31 picture ant31  路  6Comments

ggordonhall picture ggordonhall  路  3Comments

griff4692 picture griff4692  路  4Comments

josdotso picture josdotso  路  3Comments