-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
-
While building a cpp application, I noticed that I always get the warning that
fhosted
is not supported for C++.I checked where we set the parameter and found the following in
unikraft/Makefile.uk:94
From 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 amemset
by 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
-ffreestanding
parameter that will let the compiler assume that there is no standard library and thus functions likememset
are 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
-ffreestanding
takes 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
-ffreestanding
only fornolibc
to be safe with non-standard behavior but remove it for musl and newlib. Also-fhosted
seems 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