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

Add LTO support for most compilers and do some VCC fixes #14013

Merged
merged 4 commits into from
Apr 22, 2020
Merged

Add LTO support for most compilers and do some VCC fixes #14013

merged 4 commits into from
Apr 22, 2020

Conversation

Keithcat1
Copy link
Contributor

I added /link to the vcc link options so that passL works properly.
Clang_cl: Always use lld linker. It always seems to be provided on Windows, so shouldn't be a problem.
Add "user32.lib" when linking GUI apps with vcc to resolve missing import MessageBoxA.
You can define lto to enable link time optimization, It doesn't support all compilers yet.
You can define -d:lto_incremental to enable lto and additionally enable incremental linking for compilers that support it (currently just VCC, but it's very fast).
Added -d:strip to strip debug symbols at link time, for those compilers like GCC that embed COFF symbols and you don't want them.
Add /nologo to VCC compile and link tmpl in extccomp.nim.
Added /Md to compileTmpl in extccomp.nim to reduce binary size by dynamically linking to runtime.

@Araq
Copy link
Member

Araq commented Apr 18, 2020

You changed the line endings, please undo that so that I can review your PR.

@Keithcat1
Copy link
Contributor Author

OK. Should be fixed now.

@ghost
Copy link

ghost commented Apr 18, 2020

@Keithcat1 you broke them even further now :D

@ghost
Copy link

ghost commented Apr 18, 2020

Here

@Keithcat1
Copy link
Contributor Author

Keithcat1 commented Apr 18, 2020

Tried to fix it,but if it's not fixed now, I have no idea lol.
Sorry, windows user here.

@ghost
Copy link

ghost commented Apr 18, 2020

Note: this PR will also solve #3203

@@ -157,12 +157,12 @@ compiler vcc:
optSize: " /O1 ",
compilerExe: "cl",
cppCompiler: "cl",
compileTmpl: "/c$vccplatform $options $include /Fo$objfile $file",
buildGui: " /link /SUBSYSTEM:WINDOWS ",
compileTmpl: "/c$vccplatform $options $include /nologo /MD /Fo$objfile $file",
Copy link
Member

Choose a reason for hiding this comment

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

/MD is an undocumented change and I'd prefer static linking too.

@Keithcat1
Copy link
Contributor Author

How about I turn it off and add a define "dynamic_runtime" which turns it back on?

@Keithcat1
Copy link
Contributor Author

Removed it.
I'd like to add the dynamic_cruntime define, but I don't know enough abut non-windows compilers.

@Keithcat1 Keithcat1 requested a review from Araq April 22, 2020 18:18
@Araq Araq merged commit d27bc03 into nim-lang:devel Apr 22, 2020
@ghost
Copy link

ghost commented Apr 29, 2020

@Keithcat1 I've hit an error while trying to use -d:lto with Clang 9 on Linux, do you know anything about that?:
clang-9: error: invalid linker name in argument '-fuse-ld=lld'

@ghost
Copy link

ghost commented Apr 29, 2020

However when I pass "-flto" or "-flto=thin" myself directly via passC/passL LTO works with clang just fine

@Keithcat1
Copy link
Contributor Author

Hi,
Do you have the LLVM LLD linker installed?

@ghost
Copy link

ghost commented May 2, 2020

@Keithcat1 no, but clang's LTO and ThinLTO work without it

@Keithcat1
Copy link
Contributor Author

Pretty sure that's the problem then. It uses lld by default.

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