Skip to content

Commit

Permalink
Merge pull request tweag#148 from tweag/cc-toolchain-clang
Browse files Browse the repository at this point in the history
Support clang on Linux in hermetic cc toolchain
  • Loading branch information
mboes authored Nov 30, 2020
2 parents 90d141a + 6d6fc1b commit 0dd4c8a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
8 changes: 6 additions & 2 deletions nixpkgs/toolchains/cc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ in
# Keep stack frames for debugging, even in opt mode.
-fno-omit-frame-pointer
)
CXX_FLAGS=(-std=c++0x)
CXX_FLAGS=(
-x c++
-std=c++0x
)
LINK_FLAGS=(
$(
if [[ -x ${cc}/bin/ld.gold ]]; then echo -fuse-ld=gold; fi
Expand All @@ -176,10 +179,11 @@ in
# Have gcc return the exit code from ld.
add_compiler_option_if_supported -pass-exit-codes
)
)
LINK_LIBS=(
-lstdc++
-lm
)
LINK_LIBS=()
OPT_COMPILE_FLAGS=(
# No debug symbols.
# Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or
Expand Down
5 changes: 5 additions & 0 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ cc_binary(
srcs = ["cc-test.cc"],
)

cc_binary(
name = "c-test",
srcs = ["c-test.c"],
)

# Test that nixpkgs_cc_configure is selected.
cc_toolchain_test(
name = "cc-toolchain",
Expand Down
7 changes: 7 additions & 0 deletions tests/c-test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "stdio.h"
int main() {
puts("Hello world\n");
// Ensure that this is compiled as C, template is a keyword in C++.
int template = 0;
return template;
}
6 changes: 5 additions & 1 deletion tests/cc-test.cc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
int main() { return 0; }
#include <iostream>
int main() {
std::cout << "Hello world\n";
return 0;
}

0 comments on commit 0dd4c8a

Please sign in to comment.