smaeul / sun20i_d1_spl

Mainline-friendly SPL for D1
33 stars 21 forks source link

config.mk: Remove -nostdinc and use -ffreestanding #8

Closed kraj closed 2 years ago

kraj commented 2 years ago

This helps building on different kind of toolchains e.g. OE/Yocto where the standard install paths may vary and this is better to avoid to have to poke into system to find headers etc.

Signed-off-by: Khem Raj raj.khem@gmail.com

smaeul commented 2 years ago

This could bring in non-freestanding headers (like string.h) from the toolchain, right? Maybe it would be better to provide our own freestanding stdbool.h, stddef.h, etc. instead of relying on the toolchain for some headers.

kraj commented 2 years ago

This could bring in non-freestanding headers (like string.h) from the toolchain, right? Maybe it would be better to provide our own freestanding stdbool.h, stddef.h, etc. instead of relying on the toolchain for some headers.

I think -ffreestanding might be a good choice here. You want to use compiler headers and you are ok for compiler to use it from its own installation, what you really don't want is hosted environment assumptions which is what -ffreestanding will give you. I have updated the patch accordingly.

smaeul commented 2 years ago

This could bring in non-freestanding headers (like string.h) from the toolchain, right? Maybe it would be better to provide our own freestanding stdbool.h, stddef.h, etc. instead of relying on the toolchain for some headers.

I think -ffreestanding might be a good choice here. You want to use compiler headers and you are ok for compiler to use it from its own installation, what you really don't want is hosted environment assumptions which is what -ffreestanding will give you. I have updated the patch accordingly.

-ffreestanding is already in the compiler flags.

It looks like dropping -nostdinc may be fine. On my machine, with "gcc version 11.1.0" built by musl-cross-make, the program still builds and runs fine. So I think I'll merge this, and revisit if it breaks with anyone else's compiler.

kraj commented 2 years ago

This could bring in non-freestanding headers (like string.h) from the toolchain, right? Maybe it would be better to provide our own freestanding stdbool.h, stddef.h, etc. instead of relying on the toolchain for some headers.

I think -ffreestanding might be a good choice here. You want to use compiler headers and you are ok for compiler to use it from its own installation, what you really don't want is hosted environment assumptions which is what -ffreestanding will give you. I have updated the patch accordingly.

-ffreestanding is already in the compiler flags.

It looks like dropping -nostdinc may be fine. On my machine, with "gcc version 11.1.0" built by musl-cross-make, the program still builds and runs fine. So I think I'll merge this, and revisit if it breaks with anyone else's compiler.

OK let me push the old copy.

smaeul commented 2 years ago

I merged this as 4da9c518c124d6f6123bf274e449514863df3646. Thanks again for sending these cleanup PRs.