-
-
Notifications
You must be signed in to change notification settings - Fork 319
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
Mingw link issue #3270
Mingw link issue #3270
Conversation
…er, and updated mingw to remove MSVC like nologo flag
3 similar comments
Where is /NOLOGO getting set in the first place? Also a unit test can check this is working. |
I think both maybe, I suppose it matters the order the tools are loaded. It is set from the msvc.py tool, and for the test/Win32/mingw.py test, it creates a Environment(tools=['default', 'mingw']) which I think means the msvc tool runs first, adding the flag, then the mingw tool runs, removing the flag. Another case could be Environment(tools=['mingw', 'msvc']) which would not remove the flag. I guess the msvc tool should check what tools are loaded and make sure not to add that flag if the mingw tool was loaded? The test/Win32/mingw.py should probably be updated to test this case also.
Ok, I'll add a unit test so we can see it passing in the Appveyor 2015 image for this PR. |
Maybe add a unit test, but file a bug which says mingw and msvc stomp on each others flags? |
src/engine/SCons/Tool/mingw.py
Outdated
@@ -167,7 +167,8 @@ def generate(env): | |||
|
|||
env['SHOBJSUFFIX'] = '.o' | |||
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 | |||
|
|||
if 'CCFLAGS' in env: | |||
env['CCFLAGS'] = SCons.Util.CLVar(str(env['CCFLAGS']).replace('/nologo', '')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this fail badly if CCFLAGS is a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I was assuming it was CLVar, but its user settable so really should check if its CLVar and if not make it one first before doing the replace.
src/engine/SCons/Tool/mingw.py
Outdated
@@ -150,6 +150,7 @@ def generate(env): | |||
|
|||
#... but a few things differ: | |||
env['CC'] = 'gcc' | |||
env['CCFLAGS'] = SCons.Util.CLVar('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with something like
env=Environment(tools=['mslink','mingw','g++'],CCFLAGS='-myflag')
with the new code CCFLAGS will be ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at the MSVC tool and it seemed to do the same thing, so I
thought that was ok to remove flags during generate:
scons/src/engine/SCons/Tool/msvc.py
Lines 243 to 244 in e44c771
env['CCFLAGS'] = SCons.Util.CLVar('/nologo') | |
env['CFLAGS'] = SCons.Util.CLVar('') |
Seems like the best fix here is probably to fix the tests, and then for mingw to remove any /options ? (or to issue warnings about / options) |
Not sure what you mean by fix the tests, they are explicitly testing that msvc and mingw work together: Lines 165 to 166 in e44c771
I can add unit test such that fakes out the need for mingw to actually be present, and check that certain things were setup in the environment, like flags that don't have / in them.
It would have to remove it, because the msvc tool is adding it, and seems like the test indicates those tools should be able to be in the same environment. |
@@ -81,6 +81,8 @@ def _lib_emitter(target, source, env, **kw): | |||
if Verbose: | |||
print("_lib_emitter: target[0]={!r}".format(target[0].get_path())) | |||
for tgt in target: | |||
if SCons.Util.is_String(tgt): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why this started failing now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know either, I don't know the last time we had the test/Win32/mingw.py test passing to see what changed since then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of a weakness of our tests which just skip a test if the tool/setup is not there is if no CI environment is set up for a particular config, it just doesn't get tested. We have potential exposure on mingw, D, docbook, TeX, SWIG, packaging. Some of these have gotten added in recently, others fail to be added (e.g. the WiX toolset for msi packaging: apparently that code has rotted, or WiX has changed out from underneath it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Some tests will create fake tools to run with always and/or if the tool doesn't exist in the environment. However in some cases that's insufficient to test if the scons code works. Ideally we'd get a list of all tools missing and/or causing tests to be skipped at the end of a test run.. but that could be considerable work to make happen.
Any thoughts on how to better address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both Appveyor and Travis have good REST APIs for getting the logs. I could fashion a python script to get the logs of the latest master CI runs and parse the No Results at the end. That would make collecting the current list easier.
We could take that list and update a wiki page using the wiki git repository like in this example: https://stackoverflow.com/a/14673994/1644736
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it will get an exception that 'str' has no member 'attributes' just below. I'm not sure if there is somewhere further up the chain that the target should have been converted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still should be some kind of check here even if the real fix is somewhere else. Maybe a try/except? Add a warning message? I think assuming its a file if its a string is a pretty good default case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Can you change to try/except and put a comment in the except that we'd expect the target to be a Node at this point. And a # TODO to track down the why at some point?
I don't want to lose this discovery without some reasonable way of remembering to address it at some point if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chased this down and found that mingw is getting an emitter list of [mslink.py winLibEmitter, link.py shlib_emitter, mingw.py shlib_emitter]. mslink's winLibEmitter never converts its new targets to File's and just leaves them as strings:
scons/src/engine/SCons/Tool/mslink.py
Lines 144 to 154 in 9f09013
extratargets.append( | |
env.ReplaceIxes(dll, | |
'%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, | |
"LIBPREFIX", "LIBSUFFIX")) | |
# and .exp file is created if there are exports from a DLL | |
extratargets.append( | |
env.ReplaceIxes(dll, | |
'%sPREFIX' % paramtp, '%sSUFFIX' % paramtp, | |
"WINDOWSEXPPREFIX", "WINDOWSEXPSUFFIX")) | |
return (target+extratargets, source+extrasources) |
The other tools with emitters take care to convert targets to File objects:
scons/src/engine/SCons/Tool/cyglink.py
Lines 100 to 106 in 9f09013
target_strings = env.ReplaceIxes(orig_target[0], | |
'%sPREFIX' % vp, '%sSUFFIX' % vp, | |
'IMPLIBPREFIX', 'IMPLIBSUFFIX') | |
if Verbose: | |
print("_lib_emitter: target_strings=%r" % target_strings) | |
implib_target = env.fs.File(target_strings) |
So the fix can be applied by converting the the targets in mslink.py's winLibEmitter to File's. Probably still want to have a check in link.py to convert str's as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the if check instead of a try except because the current code looks cleaner than:
for tgt in target:
try:
tgt.attributes.shared = 1
except AttributeError:
tgt = env.File(tgt)
tgt.attributes.shared = 1
I am not sure about the speed up. Let me know your opinion.
c2dc898
to
dd340d5
Compare
So now with the AppendENVPath (#3281) fixed, mingw.py test is having an issue because its using the 32 bit MinGW which is first in the tools default paths. Previously it would get pushed to the back and the 64 bit mingw would be next in line. Appveyor sets an environment path for 64 bit mingw, which then fails to run the 32 bit executable. It seems we would need to update the appveyor path to point to 32 bit MinGW. Which begs the question, what if someone had multiple versions of a tool installed, how would they force scons to make sure the desired one is chosen? Seems like they would need to call PrependENVPath with which ever one they wanted after the tool was loaded. |
6d2d97f
to
b3f363b
Compare
I've wondered that... having several java versions installed isn't that uncommon (although maybe multiple jdks is less common). We include JAVA_HOME as an argument to the build to help with that. |
This is what we added TARGET_ARCH for (well 64 vs 32 bits), but currently
it's only used for MSVC.
Is there an easy way to determine if the installled mingw is 32 vs 64 bits
and could be used to select the correct installed version?
Also MINGW_VERSION maybe to say we only want a specific version (also
copying from MSVC)?
…-Bill
On Sun, Feb 3, 2019 at 11:40 AM Mats Wichmann ***@***.***> wrote:
Which begs the question, what if someone had multiple versions of a tool
installed, how would they force scons to make sure the desired one is
chosen? Seems like they would need to call PrependENVPath with which ever
one they wanted after the tool was loaded.
I've wondered that... having several java versions installed isn't that
uncommon (although maybe multiple jdks is less common). We include
JAVA_HOME as an argument to the build to help with that.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3270 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFBNJvvX-rb-zJbSWxbEzz1bdgwElplks5vJxEXgaJpZM4Z9nK1>
.
|
I am going to write that as a separate issue, and for this PR focus on getting mingw working with the first version it finds. Created #3291 for that functionality. |
b3f363b
to
88621c3
Compare
Merging. |
The test/Win32/mingw.py test on my local system and on Appveyor 2017 image. We run the 2015 image which the test gets skipped in.
These changes allow the test to pass.
Changes in this PR:
Contributor Checklist:
master/src/CHANGES.txt
directory (and read theREADME.txt
in that directory)