-fhosted and -ffreestanding Compiles Flags #668
Unanswered
marcrittinghaus
asked this question in
General
Replies: 2 comments
-
|
Hi Marc, I remember we had to do this for a quick fix during the AE process for EuroSys, it was related to a bug in DPDK. I agree with your research, we should use |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
This is now discussed in #740 , let's move the discussion there. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While building a cpp application, I noticed that I always get the warning that
fhostedis not supported for C++.I checked where we set the parameter and found the following in
unikraft/Makefile.uk:94From my understanding
-fhosted, which is the default, means that the compiler can expect the standard library to be present and have the standard-conforming implementation. So, it is possible for the compiler to optimize amemsetby replacing it with inline ASM instructions.An application like this:
could be compiled to this with
-O3:However, currently for Unikraft this will compile to:
This is due to the
-ffreestandingparameter that will let the compiler assume that there is no standard library and thus functions likememsetare more or less regular functions. Optimizing them is obviously not possible in this case.The line is introduced by commit 86fef08ac53, which states it introduces the parameters to avoid a recursive call bug for GCC 10.
I was wondering, if (1) the consequences of this where clear, and (2) why both parameters where specified because
-ffreestandingtakes precedence over-fhosted, thus potentially preventing a lot of optimizations. @vladandrew You were reviewing this. Can you remember any details?After discussing the topic also with @mschlumpp, my suggestion is to use
-ffreestandingonly fornolibcto be safe with non-standard behavior but remove it for musl and newlib. Also-fhostedseems redundant as it is the default for C (if not freestanding) and causes warnings for cpp files.For a more thorough discussion of hosted vs. freestanding also look here.
Beta Was this translation helpful? Give feedback.
All reactions