Improve the build rule for `apinames`.

* builds/unix/configure.raw: copy `CFLAGS` &
`LDFLAGS` values to `CFLAGS_BUILD` &
`LDFLAGS_BUILD`, in a self-hosting case.

* builds/unix/unix-cc.in: set `CCexe_CFLAGS` &
`CCexe_LDFLAGS` by `CFLAGS_BUILD` &
`LDFLAGS_BUILD`.

In some confused environments, simple building
like `cc -o apinames apinames.c` is no longer
able to build an executable running on the host.

The validity of `CC` is tested with consideration
of `CFLAGS` and `LDFLAGS`, thus, duplicating
`CFLAGS` & `LDFLAGS` to `CCexe_CFLAGS` &
`CCexe_LDFLAGS` (via XXX_BUILD) would be slightly
safer in a self-hosting build.

Fixes the issue #1296.
This commit is contained in:
suzuki toshiya 2024-09-03 15:59:42 +09:00
parent d2612e1c3f
commit e622c3c4cd
2 changed files with 9 additions and 1 deletions

View File

@ -62,12 +62,18 @@ if test ${cross_compiling} = yes; then
fi
rm -f a.* b.* a_out.exe conftest.*
AC_MSG_RESULT($EXEEXT_BUILD)
CFLAGS_BUILD=
LDFLAGS_BUILD=
else
CC_BUILD=${CC}
CFLAGS_BUILD=${CFLAGS}
LDFLAGS_BUILD=${LDFLAGS}
EXEEXT_BUILD=${EXEEXT}
fi
AC_SUBST(CC_BUILD)
AC_SUBST(CFLAGS_BUILD)
AC_SUBST(LDFLAGS_BUILD)
AC_SUBST(EXEEXT_BUILD)

View File

@ -113,7 +113,9 @@ LDFLAGS := @LDFLAGS@
CCraw_build := @CC_BUILD@ # native CC of building system
E_BUILD := @EXEEXT_BUILD@ # extension for executable on building system
EXPORTS_LIST := $(OBJ_DIR)/ftexport.sym
CCexe := $(CCraw_build) # used to compile `apinames' only
CCexe := $(CCraw_build) # used to compile `apinames' only, see exports.mk
CCexe_CFLAGS := @CFLAGS_BUILD@ # ditto.
CCexe_LDFLAGS := @LDFLAGS_BUILD@ # ditto.
# Library linking.