mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 04:33:45 +03:00
32 lines
1.5 KiB
Plaintext
Executable File
32 lines
1.5 KiB
Plaintext
Executable File
. ../../testutils.sh
|
|
|
|
# This test checks to make sure that Idris2's command line handling for the RefC backend is correct.
|
|
# It checks that:
|
|
# 1) Idris2 correctly finds `CFLAGS` and `LDFLAGS` in the environment,
|
|
# 2) The values in `CFLAGS` and `LDFLAGS` are separated correctly to be passed to the compiler
|
|
#
|
|
# (1) is achieved by compiling a c library (`externalc`) in a separate folder, and then explicitly
|
|
# pointing the compiler to the header files (with `-I./library/`) and shared library (with `-L./library`)
|
|
# and requesting that libexternalc.{so,dylib,dll} is linked (with `-lexternalc`). We additionally point the
|
|
# dynamic library loader to the correct location with `DYLD_LIBRARY_PATH`.
|
|
#
|
|
# (2) is achieved by passing multiple options, separated by spaces, in each of `CFLAGS` and `LDFLAGS`.
|
|
# These options are `-O3` for the c flags, and `-Wl,-pie` for the linker flags. They do not change the
|
|
# semantics of the resulting code (`-O3` simply optimises it more, and `-Wl,-S` removes debugging information
|
|
# from the final executable), but do check that we correctly split up the environment variables when we
|
|
# pass them to the C compiler.
|
|
|
|
cd ./library/
|
|
make > /dev/null
|
|
cd ..
|
|
|
|
export CFLAGS="-I./library/ -O3 ${CFLAGS}"
|
|
export LDFLAGS="-L./library/ -Wl,-S ${LDFLAGS}"
|
|
export LDLIBS="-lexternalc"
|
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:./library/"
|
|
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:./library/"
|
|
|
|
idris2 --cg refc -o cffi Main.idr
|
|
|
|
$VALGRIND ./build/exec/cffi
|