gambiteer on master
Make manual's TCP Client with T… Merge pull request #762 from ve… (compare)
feeley on master
Windows: Fix typo (compare)
feeley on master
Fix select abort for --enable-m… Windows: restrict event mask to… Avoid infinite loop on EPIPE er… and 1 more (compare)
@tck42 You can set GAMBUILD_VERBOSE=yes
or use gsc -verbose …
to get a trace of the C compiler invocations. For example:
$ GAMBUILD_VERBOSE=yes gsc foo.scm
gcc-9 -O1 -bundle -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fPIC -fno-common -mpc64 -D___SINGLE_HOST -D___DYNAMIC -I"/usr/local/Gambit/include" -o 'foo.o1' 'foo.c'
$ GAMBUILD_VERBOSE=yes gsc -exe foo.scm
gcc-9 -O1 -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fPIC -fno-common -mpc64 -D___SINGLE_HOST -I"/usr/local/Gambit/include" -c -o 'foo.o' 'foo.c'
gcc-9 -O1 -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fPIC -fno-common -mpc64 -D___SINGLE_HOST -I"/usr/local/Gambit/include" -c -o 'foo_.o' 'foo_.c'
gcc-9 -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fPIC -fno-common -mpc64 -D___SINGLE_HOST -I"/usr/local/Gambit/include" -o 'foo' 'foo_.o' 'foo.o' "/usr/local/Gambit/lib/libgambit.a”
After gsc
has generated the C file(s) it will call the ~~bin/gambuild-C
script as the last step of the compilation to invoke the C compiler and linker. When that script is called with no command line arguments it will dump all of the environment variable bindings it uses:
$ `gsc -e '(display (path-expand "~~bin/gambuild-C"))'`
C_COMPILER="gcc-9"
C_PREPROC="gcc-9 -E"
PKG_CONFIG="pkg-config"
FLAGS_OBJ=" -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fPIC -fno-common -mpc64 "
FLAGS_DYN=" -bundle -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fPIC -fno-common -mpc64 "
FLAGS_LIB=" -dynamiclib -install_name \$(libdir)/\$(LIBRARY)\$(LIB_VERSION_SUFFIX) "
FLAGS_EXE=" -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fPIC -fno-common -mpc64 "
FLAGS_OPT=" -O1"
FLAGS_OPT_RTS=" -O3"
DEFS_OBJ=" -D___SINGLE_HOST "
DEFS_DYN=" -D___SINGLE_HOST -D___DYNAMIC"
DEFS_LIB=" -D___SINGLE_HOST "
DEFS_EXE=" -D___SINGLE_HOST “
…
You can see for example that FLAGS_DYN
are the flags used for compiling a dynamically loadable object file.
If you need additional command line parameters to be passed to the C compiler you can do it manually with the -cc-options XXX
argument to gsc
, or set CFLAGS
.
$ cp contrib/GambitREPL/json*.scm .
$ gsc . json
$ gsi .
Gambit v4.9.4-39-g9a887b80
> (import json)
> (define x (call-with-input-string "{\"name\":\"John\", \"age\":30, \"car\":null}" json-read))
> (table-ref x "age")
30
> (table->list x)
(("name" . "John") ("car") ("age" . 30))
configure
script copies the current setting of CFLAGS
into the makefiles and the gambuild-C
script. So when a Scheme file is compiled by gsc
it should only be using (implicitly) the setting of CFLAGS
at that moment, i.e. there is no relationship with the build environment.
-Wl,-dT,/builddir/build/BUILD/.package_note-gambit-c-4.9.3-7.fc36.x86_64.ld
FLAGS_DYN="-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/.package_note-gambit-c-4.9.3-7.fc36.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -fmodulo-sched -freschedule-modulo-scheduled-loops -fomit-frame-pointer -fPIC -fno-common -mpc64 -rdynamic -shared"
FLAGS_LIB="-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/.package_note-gambit-c-4.9.3-7.fc36.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -rdynamic -shared"
FLAGS_EXE="-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/.package_note-gambit-c-4.9.3-7.fc36.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -fmodulo-sched -freschedule-modulo-scheduled-loops -fomit-frame-pointer -fPIC -fno-common -mpc64 -rdynamic"
FLAGS_DYN="-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/home/tck42/rpmbuild/BUILD/gambit-4.9.4/.package_note-gambit-c-4.9.4-1.fc37.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fmodulo-sched -freschedule-modulo-scheduled-loops -fomit-frame-pointer -fPIC -fno-common -mpc64 -rdynamic -shared"
FLAGS_LIB="-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/home/tck42/rpmbuild/BUILD/gambit-4.9.4/.package_note-gambit-c-4.9.4-1.fc37.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -rdynamic -shared"
FLAGS_EXE="-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/home/tck42/rpmbuild/BUILD/gambit-4.9.4/.package_note-gambit-c-4.9.4-1.fc37.x86_64.ld -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fmodulo-sched -freschedule-modulo-scheduled-loops -fomit-frame-pointer -fPIC -fno-common -mpc64 -rdynamic"
I see the problem in configure.ac
:
if test "$ENABLE_CPLUSPLUS" = yes; then
CORCXXFLAGS="$CXXFLAGS"
else
CORCXXFLAGS="$CFLAGS"
fi
FLAGS_OBJ="$CORCXXFLAGS $FLAGS_OBJ $FLAGS_OBJ_DYN $FLAGS_OBJ_DYN_LIB_EXE"
FLAGS_DYN="$LDFLAGS $CORCXXFLAGS $FLAGS_DYN $FLAGS_OBJ_DYN $FLAGS_OBJ_DYN_LIB_EXE $FLAGS_DYN_LIB"
so I was wrong and CFLAGS
from the build environment is being captured in the generated gambuild-C
script...
LDFLAGS
at the time of the ./configure
is captured and used by the Gambit makefiles (to build libgambit.a
, gsi
and gsc
) and also by the gambuild-C
script which is used to compile the standard modules (SRFIs, etc) and also user modules. I propose to add a new option to configure
that allows capturing a different set of flags in the gambuild-C
script. So ./configure --enable-gambuild-ldflags="-foo -bar"
will only capture those flags in gambuild-C
(but the LDFLAGS
that exist when the gambuild-C
script is called will still be used by the C compiler, as this is normal behavior). A ./configure --enable-gambuild-ldflags="" …
will thus only use the late binding of LDFLAGS
and a ./configure --enable-gambuild-ldflags="$LDFLAGS" …
will cause the same behavior as now. The same can be done for CFLAGS
and CXXFLAGS
.
CFLAGS
and LDFLAGS
environment variables are always used implicitly by the C compiler, so putting them in the binding of FLAGS_
is redundant at build time (when doing ./configure …;make
). It is only relevant when a programmer is using the gsc
compiler after it is built and installed. Either to generate a .oN
file with gsc foo.scm
or an executable program with gsc -exe foo.scm
(both cases invoke the gambuild-C
script). I believe your problem will be solved if the gambuild-C
script does not capture the setting that LDFLAGS
had at build time by using ./configure --enable-gambuild-ldflags=""
.