Skip to content

Commit

Permalink
Allow for Runtime-less build of GDC and GNAT
Browse files Browse the repository at this point in the history
Both D and GNAT have their own runtimes (resp. libphotos and libada).
It is still possible to build the compiler proper without any runtime,
and have an external runtime installed later. This is most commonly
found in embedded systems.

An example for D is: https://github.com/KitsunebiGames/tinyd-rt
An example for Ada: https://github.com/Fabien-Chouteau/bare_runtime

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
  • Loading branch information
dkm committed May 26, 2024
1 parent 06fad54 commit 6f4a1ba
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
28 changes: 15 additions & 13 deletions config/cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ config CC_LANG_JIT
Only select this if you know that your specific version of the
compiler supports the libgccjit.

if ! BARE_METAL

config CC_LANG_JAVA
bool
prompt "Java"
depends on CC_SUPPORT_JAVA
help
Enable building a Java compiler.

Only select this if you know that your specific version of the
compiler supports this language.

config CC_LANG_ADA
bool
prompt "Ada (EXPERIMENTAL)"
Expand All @@ -88,7 +76,8 @@ config CC_LANG_ADA
Enable building an Ada compiler.

Only select this if you know that your specific version of the
compiler supports this language.
compiler supports this language. If the target is bare, the runtime
won't be included.

config CC_LANG_D
bool
Expand All @@ -98,6 +87,19 @@ config CC_LANG_D
help
Enable building a D compiler.

Only select this if you know that your specific version of the
compiler supports this language. If the target is bare, the runtime
won't be included.

if ! BARE_METAL

config CC_LANG_JAVA
bool
prompt "Java"
depends on CC_SUPPORT_JAVA
help
Enable building a Java compiler.

Only select this if you know that your specific version of the
compiler supports this language.

Expand Down
26 changes: 25 additions & 1 deletion scripts/build/cc/gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cc_gcc_lang_list() {
[ "${CT_CC_LANG_CXX}" = "y" ] && lang_list+=",c++"
[ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_list+=",fortran"
[ "${CT_CC_LANG_ADA}" = "y" ] && lang_list+=",ada"
[ "${CT_CC_LANG_D}" = "y" ] && lang_list+=",d"
[ "${CT_CC_LANG_D}" = "y" ] && lang_list+=",d"
[ "${CT_CC_LANG_JAVA}" = "y" ] && lang_list+=",java"
[ "${CT_CC_LANG_JIT}" = "y" ] && lang_list+=",jit"
[ "${CT_CC_LANG_OBJC}" = "y" ] && lang_list+=",objc"
Expand Down Expand Up @@ -528,6 +528,22 @@ do_gcc_core_backend() {
"") extra_config+=("--disable-tls");;
esac

# In baremetal, we only build the Ada compiler without its runtime.
# The runtime will need to be provided externaly by the user.
if [ "${mode}" = "baremetal" \
-a "${CT_CC_LANG_ADA}" = "y" \
]; then
extra_config+=("--disable-libada" )
fi

# In baremetal, we only build the D compiler without its runtime.
# The runtime will need to be provided externaly by the user.
if [ "${mode}" = "baremetal" \
-a "${CT_CC_LANG_D}" = "y" \
]; then
extra_config+=("--disable-libphobos" )
fi

# Some versions of gcc have a defective --enable-multilib.
# Since that's the default, only pass --disable-multilib. For multilib,
# also enable multiarch. Without explicit --enable-multiarch, core
Expand Down Expand Up @@ -710,6 +726,14 @@ do_gcc_core_backend() {
CT_DoLog EXTRA "Building ${log_txt}"
CT_DoExecLog ALL make ${CT_JOBSFLAGS} ${core_targets_all}

# In case of baremetal, the gnat* tools are not built automatically.
if [ "${mode}" = "baremetal" \
-a "${CT_CC_LANG_ADA}" = "y" \
]; then
CT_DoLog EXTRA "Building gnattools for baremetal"
CT_DoExecLog ALL make -C gcc ${CT_JOBSFLAGS} cross-gnattools
fi

# Do not pass ${CT_JOBSFLAGS} here: recent GCC builds have been failing
# in parallel 'make install' at random locations: libitm, libcilk,
# always for the files that are installed more than once to the same
Expand Down

0 comments on commit 6f4a1ba

Please sign in to comment.