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

Fix building no_std on Windows and Linux #201

Merged
merged 1 commit into from
Jul 25, 2020
Merged

Fix building no_std on Windows and Linux #201

merged 1 commit into from
Jul 25, 2020

Conversation

udoprog
Copy link
Contributor

@udoprog udoprog commented Jul 25, 2020

Trying to fix the no_std build.

This suggests that the lto flag might be an issue. So I've made it configurable across platforms. At least this helps on my Linux box.

CC: #199 and @schungx

@schungx
Copy link
Collaborator

schungx commented Jul 25, 2020

Still failing on Windows...

@udoprog
Copy link
Contributor Author

udoprog commented Jul 25, 2020

Yeaaah, looking into it 😩

@udoprog
Copy link
Contributor Author

udoprog commented Jul 25, 2020

Can't easily figure out what's wrong with the Windows build. So I'm leaving it disabled for now. At least setting lto = true fixes the Linux build.

Feel free to keep poking at it.

@schungx
Copy link
Collaborator

schungx commented Jul 25, 2020

How about turning off lto on Windows?

@udoprog
Copy link
Contributor Author

udoprog commented Jul 25, 2020

@schungx So figured it out now. Removing lto gives more linker errors. Explanation follows.

lto=true in general eliminates the use of unused symbols, which allows it to build on Linux. This helps a bit on Windows, but apparently we either still require some crt items on msvc windows, or lto is unable to eliminate them.

The solution I've come up with is to manually link to the required crt libraries (math and crt).

I'm suspecting these are required regardless. Also note that I've attempted to use both +crt-static and compiler-builtins. The former seemingly doesn't do anything on Windows, the latter only provides some of the needed symbols (through the "mem" feature).

@schungx
Copy link
Collaborator

schungx commented Jul 25, 2020

Ah. That's it. I was using the GNU toolchain to compile on Windows. Probably an MSVC thing.

Can you use GNU on Windows to get away from it?

@udoprog
Copy link
Contributor Author

udoprog commented Jul 25, 2020

Sure, but this change doesn't hurt imo since it allows it to compile and run on both (target_env = "msvc" avoids it on gnu envs). msvc is also default for Windows.

Do you still want to change?

@schungx
Copy link
Collaborator

schungx commented Jul 25, 2020

Nah. Merge it!

@schungx schungx merged commit 4af0bbf into rhaiscript:master Jul 25, 2020
@udoprog udoprog deleted the fix-no-std-build branch July 25, 2020 10:29
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