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

when linking libc, expose libc version in builtin import, and only call c functions in std library when linking libc whose version is known to have the function #397

Closed
tiehuis opened this issue Jun 19, 2017 · 2 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@tiehuis
Copy link
Member

tiehuis commented Jun 19, 2017

getRandomBytes uses getrandom from libc. This however is fairly new, requiring the 2.25 version of glibc to compiler. If not present, this will cause a link error.

https://github.com/andrewrk/tetris fails to compile for example using an older glibc 2.23.

We could just use the syscall directly which would stop this glibc requirement. A fallback to /dev/urandom would probably be good as well. Would need to check some other source for a good set of fallback procedures.

@andrewrk andrewrk added this to the 0.1.0 milestone Jun 19, 2017
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Jun 19, 2017
@andrewrk
Copy link
Member

Currently, ability to link against libc requires knowing all the various paths to libc runtime. When you cross compile and link against libc, you have to have a libc compiled for the target and give the paths to that via command line. So we should be able to determine the version of libc that we are linking against. Then we can expose this number to the source code via the builtin import.

Then the code can check the libc version number and fall back if the libc is too old.

At this point though, I think just doing the getrandom syscall with the /dev/urandom fallback is better than status quo, and we can do the fancy version number checking later.

@andrewrk andrewrk changed the title Add fallback for getrandom call in getRandomBytes when linking libc, expose libc version in builtin import, and only call c functions in std library when linking libc whose version is known to have the function Jun 20, 2017
@andrewrk andrewrk modified the milestones: 0.2.0, 0.1.0 Jun 20, 2017
@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Oct 19, 2017
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018
@andrewrk
Copy link
Member

andrewrk commented Feb 5, 2019

Related: #1907 and #1018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants