Skip to content

provide a warning at at configure time if cc, gcc, and g++ point to a mixture of clang and gcc. Fixes issue #10959 #10964

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

Merged
merged 1 commit into from
Dec 17, 2013

Conversation

cartazio
Copy link
Contributor

@alexcrichton and others: heres a proof of concept patch for configure that (for now is OS X only) checks at the very end of the configure script if cc, gcc, and g++ possibly point to the same compiler or not.

The way its currently done is i call cc --version, gcc --version and g++ --version and check if theres any matchings for the word clang, gcc or g++. So it doesn't rule out miss matched gcc versions or the like, but thats a bit more implausible I think.

@cartazio
Copy link
Contributor Author

this addresses issue #10959

@cartazio
Copy link
Contributor Author

also I'd like to thank evan cofsky for helping me hack out the sh scripting needed for this.


gccIsGCC () {
gcc --version 2>/dev/null | grep -q gcc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many empty lines? (nb. i'm about to rebase your suggestion onto my branch)

@cartazio
Copy link
Contributor Author

Excellent suggestion. I'll make those changes later this afternoon.

@cartazio
Copy link
Contributor Author

I just updated the commit with the earlier feedback. Should I rebase the commit ontop of master?

@cartazio
Copy link
Contributor Author

updated to be on top of current master

@cartazio
Copy link
Contributor Author

good point on the echo pieces.

--enable-clang actually didn't work when I was trying to get rust working building though, though I could be misremembering.
Somehow the mixup of the cc,gcc and g++ were interacting with that, though I've not gone back to repro that problem.

echo this can create confusing build failures at link time.
echo Please run cc --version, gcc --version and g++ --version to check.
echo If they are different, change the cc gcc and g++ in your path
echo point to the same compiler version, or alternatively try --enable-clang.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the if [ $(uname ... check if --enable-clang was passed, so that this error message isn't printed in that case?

(Also, I'm not 100% sure on style, but I would personally indent all these echo statements.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the right way for me to answer that is to see if i can do a test build correctly with --enable-clang + gcc pointing to gcc, and cc and g++ pointing to clang.

i don't care about the indentation either way, i'll make that change if need be

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm, --enable clang seems to work under the mixed cc / g++ etc. I'll double check a wee bit more, then figure out adding that conditional about enable clang

@cartazio
Copy link
Contributor Author

hrm, so it looks like currently the configure script https://github.com/mozilla/rust/blob/master/configure#L554-L563
detects if gcc is an alias for clang.

# OS X 10.9, gcc is actually clang. This can cause some confusion in the build
# system, so if we find that gcc is clang, we should just use clang directly.
if [ $CFG_OSTYPE = apple-darwin -a -z "$CFG_ENABLE_CLANG" ]
then
    CFG_OSX_GCC_VERSION=$("$CFG_GCC" --version 2>&1 | grep "Apple LLVM version")
    if [ $? -eq 0 ]
    then
        step_msg "on OS X 10.9, forcing use of clang"
        CFG_ENABLE_CLANG=1
        putvar CFG_ENABLE_CLANG
    fi
fi

perhaps I should put my warning logic there? or some suitable adaptation thereof

@alexcrichton
Copy link
Member

Yes, that is a good place for this version detection, which would be in the else clause of the inner if. I also think that it should abort the configure with a message suggesting --enable-clang instead of getting silently buried in all the output.

@cartazio
Copy link
Contributor Author

updated it again with the current feedback

@cartazio
Copy link
Contributor Author

fixed it up a bit, should be more correct.

@cartazio
Copy link
Contributor Author

@alexcrichton thoughts?

…ure of clang and gcc. Fixes issue #10959

Signed-off-by: Carter Tazio Schonwald <carter.schonwald@gmail.com>
bors added a commit that referenced this pull request Dec 17, 2013
 @alexcrichton and others: heres a proof of concept patch for configure that (for now is OS X only) checks at the very end of the configure script if ``cc``, ``gcc``, and ``g++`` possibly point to the same compiler or not.

The way its currently done is i call ```cc  --version```, ``gcc --version`` and ``g++ --version`` and check if theres any matchings for the word ``clang``, ``gcc`` or ``g++``.  So it doesn't rule out miss matched gcc versions or the like, but thats a bit more implausible I think.
@bors bors closed this Dec 17, 2013
@bors bors merged commit d952553 into rust-lang:master Dec 17, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 30, 2023
New lints ['`needless_pub_self`], [`pub_with_shorthand`] and [`pub_without_shorthand`]

Closes rust-lang#10963
Closes rust-lang#10964

changelog: New lints ['`needless_pub_self`], [`pub_with_shorthand`] and [`pub_without_shorthand`]
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.

4 participants