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

Tune CC and CXX assignment #1336

Merged
merged 1 commit into from
Dec 2, 2016
Merged

Conversation

PeterDaveHello
Copy link
Collaborator

No description provided.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

I'm not sure why these changes are being made - the whole point is to override the CXX and CC settings, since they are often both set, and wrong.

make='gmake'
MAKE_CXX='CXX=c++'
elif [ "${NVM_OS}" = 'aix' ]; then
if [ "${NVM_OS}" = 'freebsd' ] || [ "${NVM_OS}" = 'aix' ]; then
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to keep all the conditions for each OS separate - ie, i think it's more maintainable to repeat the make assignment rather than have multiple confusing code paths for the same OS.

make='gmake'
fi
if nvm_has "clang++" && nvm_has "clang" && nvm_version_greater_than_or_equal_to nvm_clang_version 3.5 ; then
if [ "${NVM_OS}" = 'freebsd' ] || [ "${NVM_OS}" = 'darwin' ]; then
[ -z "${CXX-}" ] && MAKE_CXX='CC=cc CXX=c++'
Copy link
Member

Choose a reason for hiding this comment

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

this should use an if/else, or else it will fail on set -e.

Why is this being conditionally set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmmm ... I didn't understand the being conditionally set means, would you mind to explain about this? Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

I'm asking why you're not always setting MAKE_CXX

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the user set CXX and CC, we'll overwrite it and make it not working, so only when CXX and CC not set, we set it.

Copy link
Member

Choose a reason for hiding this comment

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

right - we want to overwrite it, because it's often set to the wrong values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you may need to specify CXX=clang++-3.8 CC=clang-3.8

Copy link
Member

Choose a reason for hiding this comment

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

nvm has always blindly overridden CC and CXX before, and i've never once seen a request to override those things. Why is now different?

Copy link
Collaborator Author

@PeterDaveHello PeterDaveHello Nov 29, 2016

Choose a reason for hiding this comment

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

We ONLY set it for FreeBSD before, I don't know how many FreeBSD users are using nvm, but I guess most of the users is on Linux distros, and then MacOS, no CXX, CC were set in this two situations, so it makes sense there is no issue about it.

If we'll always overwrite CC and CXX, then export CC and CXX in .travis.yml makes no sense, why do we export that two variables there?

For distros like Ubuntu 12.04/14.04 doesn't have clang new enough, install clang from ppa or llvm official source will make the newer versions called clang-3.x, then nvm can't not detect it.

After all, what's the reason why we should not respect the environment variable? Do we really got a problem that the incorrect CXX and CC environment variable set made the build failed?

Copy link
Member

Choose a reason for hiding this comment

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

That's a fair point, I suppose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So are we good to go now? Or any part need me to update? Thanks.

 - Also set CC for Freebsd, not only CXX

 - Also set CC=cc, CXX=c++ on Mac OS by default as upstream

Reference:
https://github.com/nodejs/node/blob/1bd871655a8b76fa3be1e3c6c325efa74c86fcd9/configure#L16-L17
'freebsd')
make='gmake'
if [ -z "${CXX-}" ]; then
MAKE_CXX='CC=cc CXX=c++'
Copy link
Member

Choose a reason for hiding this comment

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

do we instead want MAKE_CXX = "CC=${CC:-cc} CXX=${CXX:-c++}", without the condition?

Copy link
Collaborator Author

@PeterDaveHello PeterDaveHello Dec 1, 2016

Choose a reason for hiding this comment

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

Will be the same result, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm fine with MAKE_CXX = "CC=${CC:-cc} CXX=${CXX:-c++}"

Copy link
Member

Choose a reason for hiding this comment

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

Slightly different - as-is, if "CC" is set but "CXX" is unset, then "CC" will be overridden - but if the reverse is true, "CXX" won't get set.

;;
'darwin')
if [ -z "${CXX-}" ]; then
MAKE_CXX='CC=cc CXX=c++'
Copy link
Member

Choose a reason for hiding this comment

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

also here, do we instead want MAKE_CXX = "CC=${CC:-cc} CXX=${CXX:-c++}", without the condition?

;;
esac
if nvm_has "clang++" && nvm_has "clang" && nvm_version_greater_than_or_equal_to nvm_clang_version 3.5 \
&& [ -z "${CC-}" ] && [ -z "${CXX-}" ] ; then
Copy link
Member

Choose a reason for hiding this comment

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

what if one is specified but the other is not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmmm... will be a little bit tricky?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe also MAKE_CXX = "CC=${CC:-cc} CXX=${CXX:-c++}"?

Copy link
Member

Choose a reason for hiding this comment

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

That seems good.

@PeterDaveHello
Copy link
Collaborator Author

All updated!

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM after this change

case "${NVM_OS}" in
'freebsd')
make='gmake'
MAKE_CXX="CC=${CC:-cc} CXX=${CXX:-c++}"
Copy link
Member

Choose a reason for hiding this comment

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

hm, this seems like an oversight - there's no local MAKE_CXX declaration in this function. let's add one above the case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done 👍

@ljharb ljharb force-pushed the fix-CC-CXX branch 2 times, most recently from 61123c2 to 4577149 Compare December 2, 2016 07:27
@ljharb ljharb merged commit 4577149 into nvm-sh:master Dec 2, 2016
@PeterDaveHello PeterDaveHello deleted the fix-CC-CXX branch December 2, 2016 08:43
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.

2 participants