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

Attempt to support clang (osx/freebsd) #8

Merged
merged 1 commit into from
Feb 14, 2017
Merged

Conversation

asottile
Copy link
Owner

Resolves #7

CC @nils-werner

I assume there's a better way of detecting the compiler but this seems to work?

@nils-werner
Copy link

I see you are trying to infer the Go compiler from the setuptools compiler. I don't know if they are always the same and if things would even work if they weren't. However I would still argue that specifically asking Go for its compiler would be the more consistent solution.

The following asks go (go env CXX) for its compiler instead of asking the setuptools one.

def _guess_compiler():
    # Attempt to guess the compiler
    out = subprocess.check_output(('go', 'env', 'CXX'))
    for possible in ('clang', 'gcc'):  # pragma: no cover (platform specific)
        if possible.encode('US-ASCII') in out:
            return possible
    else:  # pragma: no cover (platform specific)
        # Patches welcome!
        return 'gcc'

def _get_ldflags():
    cc = _guess_compiler()
    return {
        'clang': '-Wl,-undefined,dynamic_lookup',
        'gcc': '-Wl,--unresolved-symbols=ignore-all',
    }[cc]

What do you think?

@asottile
Copy link
Owner Author

I actually went with a solution based on a question I asked on SO: http://stackoverflow.com/questions/42195333/detect-compiler-and-use-compiler-specific-flags-when-invoking

Also I think I want CC (CXX is the c++ compiler)

@asottile asottile force-pushed the add_clang_support branch 3 times, most recently from fa83dc5 to 09e2bc6 Compare February 14, 2017 01:39
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

Successfully merging this pull request may close these issues.

None yet

2 participants