mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 12:42:02 +03:00
commit
bfea7d785a
@ -66,3 +66,23 @@ Gambit Directives
|
||||
.. code-block::
|
||||
|
||||
$ idris2 --codegen chez --directive extraRuntime=/path/to/extensions.scm -o main Main.idr
|
||||
|
||||
* ``--directive C``
|
||||
|
||||
Compile to C.
|
||||
|
||||
Gambit Environment Configurations
|
||||
=================================
|
||||
|
||||
* ``GAMBIT_GSC_BACKEND``
|
||||
|
||||
The ``GAMBIT_GSC_BACKEND`` variable controls which C compiler Gambit will use during compilation. E.g. to use clang:
|
||||
|
||||
::
|
||||
|
||||
$ export GAMBIT_GSC_BACKEND=clang
|
||||
|
||||
Gambit after version v4.9.3 supports the ``-cc`` option, which configures
|
||||
the compiler backend Gambit will use to build the binary. Currently to
|
||||
get this functionality Gambit needs to be built from source, since it is
|
||||
not yet available in a released version.
|
||||
|
@ -38,6 +38,13 @@ findGSC =
|
||||
do env <- getEnv "GAMBIT_GSC"
|
||||
pure $ fromMaybe "/usr/bin/env gsc" env
|
||||
|
||||
findGSCBackend : IO String
|
||||
findGSCBackend =
|
||||
do env <- getEnv "GAMBIT_GSC_BACKEND"
|
||||
pure $ case env of
|
||||
Nothing => ""
|
||||
Just e => " -cc " ++ e
|
||||
|
||||
schHeader : String
|
||||
schHeader = "; @generated\n
|
||||
(declare (block)
|
||||
@ -387,9 +394,15 @@ compileExpr c tmpDir outputDir tm outfile
|
||||
libsname <- compileToSCM c tm srcPath
|
||||
libsfile <- traverse findLibraryFile $ map (<.> "a") (nub libsname)
|
||||
gsc <- coreLift findGSC
|
||||
let cmd = gsc ++
|
||||
" -exe -cc-options \"-Wno-implicit-function-declaration\" -ld-options \"" ++
|
||||
(showSep " " libsfile) ++ "\" -o \"" ++ execPath ++ "\" \"" ++ srcPath ++ "\""
|
||||
gscBackend <- coreLift findGSCBackend
|
||||
ds <- getDirectives Gambit
|
||||
let gscCompileOpts =
|
||||
case find (== "C") ds of
|
||||
Nothing => gscBackend ++ " -exe -cc-options \"-Wno-implicit-function-declaration\" -ld-options \"" ++
|
||||
(showSep " " libsfile) ++ "\""
|
||||
Just _ => " -c"
|
||||
let cmd =
|
||||
gsc ++ gscCompileOpts ++ " -o \"" ++ execPath ++ "\" \"" ++ srcPath ++ "\""
|
||||
ok <- coreLift $ system cmd
|
||||
if ok == 0
|
||||
then pure (Just execPath)
|
||||
|
Loading…
Reference in New Issue
Block a user