From 1488d23f96a4d120bf5ec9064256a4df3bfe6c89 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 18 Feb 2024 18:06:00 +0000 Subject: [PATCH] Use --without-system-cc to disable AOT compilation --- .github/workflows/build-test.yml | 4 ++-- configure.ac | 32 ++++++++++++++++++-------------- src/cgen.c | 8 ++++++-- src/nvc.c | 14 +++++++++----- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e38af2e4..9dfb91dc 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -485,11 +485,11 @@ jobs: run: | echo $PATH export PATH=$PATH:/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin - which candle mkdir build cd build bash ../configure --enable-static-llvm --enable-tcl \ - --enable-verilog --enable-gui CFLAGS="-O2" --prefix=`pwd`/installdir + --enable-verilog --enable-gui CFLAGS="-O2" \ + --prefix=`pwd`/installdir --without-system-cc - name: Build run: make -C build - name: Install diff --git a/configure.ac b/configure.ac index 0d19c9b5..f488fbec 100644 --- a/configure.ac +++ b/configure.ac @@ -360,7 +360,7 @@ if test -n "$linker_path"; then fi # CC may constain unwanted -std=... option. -cc_bare="$(which ${CC%% *})" +cc_bare=${CC%% *} AC_ARG_WITH([system-cc], [AS_HELP_STRING([--with-system-cc=PATH], @@ -368,21 +368,25 @@ AC_ARG_WITH([system-cc], [system_cc="$withval"], [system_cc="$cc_bare"]) -AC_MSG_CHECKING([if $system_cc executable exists]) -AS_IF([test -x $system_cc], - [AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no]) - AC_PATH_PROG([system_cc], ["$system_cc"], - [AC_MSG_ERROR([system C compiler $system_cc not found])])]) +if test x$system_cc != xno; then + AC_MSG_CHECKING([if $system_cc executable exists]) + AS_IF([test -x $system_cc], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_PATH_PROG([system_cc], ["$system_cc"], + [AC_MSG_ERROR([system C compiler $system_cc not found])])]) -case $host_os in - *cygwin*|msys*|mingw32*) - # Do not hard-code full path on Windows - system_cc="$(basename $system_cc)" - ;; -esac + case $host_os in + *cygwin*|msys*|mingw32*) + # Do not hard-code full path on Windows + system_cc="$(basename $system_cc)" + ;; + esac -AC_DEFINE_UNQUOTED([SYSTEM_CC], ["$system_cc"], [System compiler]) + AC_DEFINE_UNQUOTED([SYSTEM_CC], ["$system_cc"], [System compiler]) +else + AC_DEFINE_UNQUOTED([BOOTSTRAP_CC], ["$cc_bare"], [Bootstrap compiler]) +fi case $host_os in *cygwin*|msys*|mingw32*) diff --git a/src/cgen.c b/src/cgen.c index 2797122a..5058c2d9 100644 --- a/src/cgen.c +++ b/src/cgen.c @@ -166,11 +166,15 @@ static void cgen_link_arg(const char *fmt, ...) static void cgen_linker_setup(void) { -#ifdef LINKER_PATH +#if defined LINKER_PATH cgen_link_arg("%s", LINKER_PATH); cgen_link_arg("--eh-frame-hdr"); -#else +#elif defined SYSTEM_CC cgen_link_arg("%s", SYSTEM_CC); +#elif defined BOOTSTRAP_CC + cgen_link_arg("%s", BOOTSTRAP_CC); +#else + fatal_trace("configured without external C compiler or linker"); #endif #if defined __APPLE__ diff --git a/src/nvc.c b/src/nvc.c index ac0f670c..86a36006 100644 --- a/src/nvc.c +++ b/src/nvc.c @@ -56,6 +56,12 @@ #define GIT_SHA_ONLY(x) #endif +#if !defined HAVE_LLVM || !defined SYSTEM_CC +#define DEFAULT_JIT true +#else +#define DEFAULT_JIT false +#endif + typedef struct { jit_t *jit; unit_registry_t *registry; @@ -364,7 +370,7 @@ static int elaborate(int argc, char **argv, cmd_state_t *state) { 0, 0, 0, 0 } }; - bool use_jit = false, no_save = false; + bool use_jit = DEFAULT_JIT, no_save = false; cover_mask_t cover_mask = 0; char *cover_spec_file = NULL; int cover_array_limit = 0; @@ -471,8 +477,6 @@ static int elaborate(int argc, char **argv, cmd_state_t *state) if (error_count() > 0) return EXIT_FAILURE; - const bool aot_codegen = !use_jit NOT_LLVM_ONLY(&& false); - char *pack_name LOCAL = xasprintf("_%s.pack", istr(top_level)); char *dll_name LOCAL = xasprintf("_%s." DLL_EXT, istr(tree_ident(top))); @@ -486,7 +490,7 @@ static int elaborate(int argc, char **argv, cmd_state_t *state) progress("saving library"); } - if (!no_save && !aot_codegen) { + if (use_jit && !no_save) { FILE *f = lib_fopen(work, pack_name, "wb"); if (f == NULL) fatal_errno("fopen: %s", pack_name); @@ -503,7 +507,7 @@ static int elaborate(int argc, char **argv, cmd_state_t *state) progress("writing JIT pack"); } - if (aot_codegen) { + if (!use_jit) { LLVM_ONLY(cgen(top, state->registry, state->jit)); // Must discard current JIT state to load AOT library later -- 2.39.2