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

SConscript.boot do not recognize clang++ compiler if not given by name. #96

Open
mazhe opened this issue Dec 10, 2017 · 0 comments
Open

Comments

@mazhe
Copy link

mazhe commented Dec 10, 2017

Hello,

I'm trying to build swift on a FreeBSD system, and one of my issues is that the SConscript.boot code try to identify compiler by executable basename:

if os.path.basename(env["CXX"]).startswith(("clang", "clang++")) :

First, accepting "clang" as a valid C++ compiler when it's the C driver is a bit weird, and this will obviously won't work if clang++ is used under any other valid name such as c++ or clang++50 etc. I'm not sure how scons usually work out compilers IDs, but in this case the only way I see would be to get it from a "$CXX -v" invokation, what would you think of the following?

--- BuildTools/SCons/SConscript.boot.orig	2017-11-28 12:51:50 UTC
+++ BuildTools/SCons/SConscript.boot
@@ -1,4 +1,4 @@
-import sys, os, re, platform, hashlib
+import sys, os, re, platform, hashlib, subprocess
 sys.path.append(Dir("#/BuildTools/SCons").abspath)
 
 ################################################################################
@@ -343,7 +343,9 @@ elif env["PLATFORM"] == "sunos" :
     #env.Append(CXXFLAGS = ["-z verbose"])
     pass
 else :
-    if os.path.basename(env["CXX"]).startswith(("clang", "clang++")) :
+    cxx_p = subprocess.Popen([os.path.basename(env["CXX"]),"-v"], stderr=subprocess.PIPE)
+    cxx_id = cxx_p.communicate()[1]
+    if "clang" in cxx_id:
         env.Append(CXXFLAGS = [
             "-Weverything",
             "-Wno-unknown-warning-option", # To stay compatible between CLang versions

Thanks for that promising client & keep up the work!

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

1 participant