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

/O2 is incompatible with /RTC1 #12

Merged
merged 2 commits into from
May 25, 2015
Merged

/O2 is incompatible with /RTC1 #12

merged 2 commits into from
May 25, 2015

Conversation

tvandijck
Copy link
Contributor

No description provided.

@starkos
Copy link
Member

starkos commented Apr 6, 2015

This one fails several unit tests due to the changed behavior.

@TurkeyMan
Copy link
Contributor

It would help to rebase all these PR's on latest so they pipe through travis.

@tvandijck
Copy link
Contributor Author

I'll give that a shot...

@starkos
Copy link
Member

starkos commented May 10, 2015

This one is still failing several of the unit tests due to the flag change.

@tvandijck
Copy link
Contributor Author

yes, do you want me to fix the tests? or do we just not want this one?
basically what I'm getting in unit-tests is a couple of extra "DefaultRuntime" flags here and there.. nothing harmless really, and from visual studio's perspective not a behavior change.

@starkos
Copy link
Member

starkos commented May 11, 2015

Just need the tests to pass with the new behavior.

@tvandijck
Copy link
Contributor Author

All fixed...

starkos added a commit that referenced this pull request May 25, 2015
/O2 is incompatible with /RTC1
@starkos starkos merged commit b23fcc0 into premake:master May 25, 2015
@tvandijck tvandijck deleted the pr6 branch May 26, 2015 17:58
@starkos
Copy link
Member

starkos commented Jun 7, 2015

I'm getting pushback on this change. We have projects that have been building fine for months now getting new <BasicRuntimeChecks>Default</BasicRuntimeChecks> markup added, and there doesn't seem to be a good reason for it. I seem to recall a thread somewhere about why this change was necessary but I can't find it now. Visual Studio seems to work just fine without this value set; should be done conditionally in project scripts instead?

filter "Release"
   flags "NoRuntimeChecks"

@tvandijck
Copy link
Contributor Author

Well, I really want to stay away from flags as much as possible... they are so hard to 'override' for projects and can only be removed to revert to the default behaviour, which is sometimes exactly NOT what I want....

anyway, this thing fixes the following error:
1>cl : Command line error D8016: '/O2' and '/RTC1' command-line options are incompatible

So if you create a combination of RuntimeChecks, and /O2 (optimized build), your project simply does not build. Arguably this can be fixed with a filter or some other setting in premake, but my argument is that premake should NEVER EVER create combinations that are invalid.

I'm all for "fixing" this in a better way that does not generate the extra output if it's not needed, but I do like to have this fix.

@starkos
Copy link
Member

starkos commented Jun 8, 2015

anyway, this thing fixes the following error:
1>cl : Command line error D8016: '/O2' and '/RTC1' command-line options are incompatible

We're not seeing this issue here. I will investigate further and see if I can understand why.

@tvandijck
Copy link
Contributor Author

what version of visual studio? I'm seeing this with 2013...

@TurkeyMan
Copy link
Contributor

I think it's VS version specific.

So if you create a combination of RuntimeChecks, and /O2 (optimized build), your project simply does not build.

Isn't this something that should be caught in a validation step somewhere? We do need a mechanism to perform/extend the validation process in the bake.
Or would you want premake to attempt to correct the situation intelligently, rather than emit an error detailing invalid build configuration?

@tvandijck
Copy link
Contributor Author

Isn't this something that should be caught in a validation step somewhere?

No, I don't think you can... because this is unique to visual studio. Maybe clang does in fact allow for this in optimized builds...

Or would you want premake to attempt to correct the situation intelligently,

that is what I attempted to do with the commit. In the visual studio action, I ignore the runtime check setting for optimized builds..

@starkos
Copy link
Member

starkos commented Jun 10, 2015

Okay, I've been poking at this one a bit and have some findings…

If I manually create a sample C++ project with VS 2013, it does not contain any BasicRuntimeChecks elements in the project XML. If I open the project in VS and bring up the project properties, I see that Basic Runtime Checks is set to "Both" (/RTC1) for the debug build, and "Default" (no flag) for the release build.

So I tried this Premake script:

solution "MySolution"
    configurations { "Debug", "Release" }

filter "Debug"
    flags "Symbols"

filter "Release"
    optimize "speed"

project "MyProject"
    kind "ConsoleApp"
    files "hello.cpp"

I get the same result: no BasicRuntimeChecks element in the project file, "Both" for the debug build, "Default" for the release build, /O2 optimization and everything builds fine.

So here's the $1M question: since there iares no BasicRuntimeChecks element in the project file, what criteria is VS using to determine when to turn them on? If I could figure that out, I could apply a narrower test and only write the element when it was really needed. (Or: are you somehow adding that element through a customization of your own? Because the public version of Premake has no way to set that value to anything other than "Default").

Would it be possible to get an example project that demonstrates the problem, if I were to reverse this change? I could then compare the settings to my default project and figure out what is driving VS to turn on /RTC1.

@starkos
Copy link
Member

starkos commented Jun 10, 2015

Oh, and per your previous point…

really want to stay away from flags as much as possible... they are so hard to 'override'

…this seems like a really good candidate to move to an API call. VS supports multiple values, so it really isn't the toggle that the flag would imply anyway.

@tvandijck
Copy link
Contributor Author

Here is a repo:

solution "MySolution"
    configurations { "DebugSlow", "DebugFast", "Release" }

filter "Debug*"
    flags "Symbols"

filter "DebugFast"
    optimize "speed"
    runtime  "debug"

filter "Release"
    optimize "speed"

project "MyProject"
    kind "ConsoleApp"
    files "hello.cpp"

@tvandijck
Copy link
Contributor Author

and just to clarify, the "DebugFast" config is where it goes wrong.... since it takes on the default visual studio properties from the "debug" config, but we're doing an optimized build with the debug runtime.

the debug runtime is the important part here, because of this little piece in Microsoft.Cl.Common.props

<ItemDefinitionGroup Condition="'$(UseDebugLibraries)' == 'true'">
    <ClCompile>
      <RuntimeLibrary                   Condition="'%(ClCompile.RuntimeLibrary)'                == ''">MultiThreadedDebugDll</RuntimeLibrary>
      <BasicRuntimeChecks               Condition="'%(ClCompile.BasicRuntimeChecks)'            == ''">EnableFastChecks</BasicRuntimeChecks>

@tvandijck
Copy link
Contributor Author

given that actually, I think what we could do is:

if cfg.flags.NoRuntimeChecks or (config.isOptimizedBuild(cfg) and runtime=="Debug") then

since that is ultimately the entire condition under which it fails.

tvandijck pushed a commit to tvandijck/premake-core that referenced this pull request May 11, 2016
samsinsane pushed a commit to LORgames/premake-core that referenced this pull request Apr 5, 2018
Add linking support for externally referenced files.
vadz added a commit to vadz/premake-core that referenced this pull request Aug 27, 2023
Rename buffer_init() to avoid clashing with a function with the same
name in luasocket code: under Linux, due to the of "flat" ELF
namespaces, when luasocket shared library is loaded into premake process
the existing premake function is used instead of the function defined in
luasocket code, resulting in luasocket buffer not being properly
initialized which, in turn, leads to mysterious crashes as soon as it's
used, e.g. dereferencing null timeout field:

	(gdb) bt
	#0  0x00007ffff7cce642 in timeout_markstart (tm=0x0) at ../../binmodules/luasocket/src/timeout.c:116
	premake#1  0x00007ffff7cc7618 in buffer_meth_receive (L=0x5555557882a8, buf=0x5555559044a0) at ../../binmodules/luasocket/src/buffer.c:113
	premake#2  0x00007ffff7ccd545 in meth_receive (L=0x5555557882a8) at ../../binmodules/luasocket/src/tcp.c:135
	premake#3  0x000055555558c1cc in luaD_precall (L=0x5555557882a8, func=0x5555558e36b0, nresults=1) at ../../contrib/lua/src/ldo.c:434
	premake#4  0x00005555555a971f in luaV_execute (L=0x5555557882a8) at ../../contrib/lua/src/lvm.c:1134
	premake#5  0x000055555558c555 in luaD_call (L=0x5555557882a8, func=0x5555558e3640, nResults=0) at ../../contrib/lua/src/ldo.c:499
	premake#6  0x000055555558c5b3 in luaD_callnoyield (L=0x5555557882a8, func=0x5555558e3640, nResults=0) at ../../contrib/lua/src/ldo.c:509
	premake#7  0x0000555555588af5 in lua_callk (L=0x5555557882a8, nargs=2, nresults=0, ctx=0, k=0x0) at ../../contrib/lua/src/lapi.c:925
	premake#8  0x00005555555af4f2 in hookf (L=0x5555557882a8, ar=0x7fffffffd270) at ../../contrib/lua/src/ldblib.c:316
	premake#9  0x000055555558bafb in luaD_hook (L=0x5555557882a8, event=2, line=273) at ../../contrib/lua/src/ldo.c:269
	premake#10 0x000055555558b284 in luaG_traceexec (L=0x5555557882a8) at ../../contrib/lua/src/ldebug.c:687
	premake#11 0x00005555555a6b71 in luaV_execute (L=0x5555557882a8) at ../../contrib/lua/src/lvm.c:801
	premake#12 0x000055555558c555 in luaD_call (L=0x5555557882a8, func=0x555555889360, nResults=1) at ../../contrib/lua/src/ldo.c:499
	premake#13 0x000055555558c5b3 in luaD_callnoyield (L=0x5555557882a8, func=0x555555889360, nResults=1) at ../../contrib/lua/src/ldo.c:509
	premake#14 0x0000555555588b60 in f_call (L=0x5555557882a8, ud=0x7fffffffdbb0) at ../../contrib/lua/src/lapi.c:943
	premake#15 0x000055555558b5a5 in luaD_rawrunprotected (L=0x5555557882a8, f=0x555555588b2b <f_call>, ud=0x7fffffffdbb0)
	    at ../../contrib/lua/src/ldo.c:142
	premake#16 0x000055555558cd85 in luaD_pcall (L=0x5555557882a8, func=0x555555588b2b <f_call>, u=0x7fffffffdbb0, old_top=64, ef=48)
	    at ../../contrib/lua/src/ldo.c:729
	premake#17 0x0000555555588c28 in lua_pcallk (L=0x5555557882a8, nargs=0, nresults=1, errfunc=3, ctx=0, k=0x0)
	    at ../../contrib/lua/src/lapi.c:969
	premake#18 0x0000555555584734 in premake_pcall (L=0x5555557882a8, nargs=0, nresults=1) at ../../src/host/premake.c:287
	premake#19 0x0000555555584867 in premake_execute (L=0x5555557882a8, argc=5, argv=0x7fffffffdd98,
	    script=0x555555685052 "src/_premake_main.lua") at ../../src/host/premake.c:316
	premake#20 0x000055555558535e in main (argc=5, argv=0x7fffffffdd98) at ../../src/host/premake_main.c:19

For consistency, rename all the other buffer_xxx functions too, even
though they don't conflict with anything right now.
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.

3 participants