-
Notifications
You must be signed in to change notification settings - Fork 66
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
allow tomsfastmath to be built without stdlib #34
base: develop
Are you sure you want to change the base?
Conversation
The only use of `malloc`/`free` in tomfastmath is in src/numtheory/fp_prime_random_ex.c, and the size required can be calculated from the function arguments, so we can just use a variable-length automatic array instead. Variable-length automatic arrays are a C99 feature, and TFM already doesn’t compile as C90, so we might as well take advantage of it.
fp_ident is the only place tomsfast math uses string manipulation functions when built as a library. This commit replaces them with safe, trivial functions for concatonating static strings and numbers together.
This commit enables tomsfastmath to be built with `--no-standard-libraries` provided `TFM_NO_STDLIB` is defined, which happens automatically if a web assembly build target is detected. The only functionality this disables is the `fp_rand` function.
#if TFM_NO_STDLIB | ||
/* do nothing */ |
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.
This worries me a bit, 'cause it allows anyone to defined -DTOM_NO_STDLIB=1
regardless of compiler, and when looking through the code, this feature makes heavy use of GCC features.
People might want to build without having to link with stdlib for other reasons than webasm...
It's possible that this should simply be documented with fierce warnings not to try this with other compilers than GCC or derivatives thereof (like clang)
I use clang for webasm builds, it does work there. I can add some guards to try to verify the compiler, though.
…On September 16, 2024 6:17:20 AM GMT+01:00, Richard Levitte ***@***.***> wrote:
@levitte commented on this pull request.
> +#if TFM_NO_STDLIB
+/* do nothing */
This worries me a bit, 'cause it allows anyone to defined `-DTOM_NO_STDLIB=1` regardless of compiler, and when looking through the code, this feature makes heavy use of GCC features.
People might want to build without having to link with stdlib for other reasons than webasm...
It's possible that this should simply be documented with fierce warnings not to try this with other compilers than GCC or derivatives thereof (like clang)
|
That would be a good thing, methinks
|
This commit enables tomsfastmath to be built with
--no-standard-libraries
providedTFM_NO_STDLIB
is defined, which happens automatically if a web assembly build target is detected.The only functionality this disables is the
fp_rand
function.This pull request is also contains the required changes in #32 and #33.