on master help sign in
Merge pull request #4095 from asandroq/fix-flag-argument-order

Pass directives to C backend in given order (#4078)

commiteabb922ade88552bb9852aab19f4fd2e2de67067 authorAhmad Salim Al-Sibahi <asal@itu.dk> dateWed 4 Oct 2017, 09:30 (9 years ago) parentf9846574e326e4
7 files changed+38−4
CHANGELOG.md+2 CONTRIBUTORS+1 src/Idris/AbsSyntax.hs+3−3 test/TestData.hs+2−1 test/directives003/directives003.idr+11 test/directives003/expected+6 test/directives003/run+13
CHANGELOG.md+2
@@ -19,6 +19,8 @@
1919+ Private functions are no longer visible in the REPL except for modules
2020 that are explicitly loaded.
2121+ The --interface option now creates CommonJS modules on the node backend.
22++ The C backend now pass arguments to the C compiler in the same order
23+ as they were given in the source files.
2224
2325# New in 1.1.1
2426
CONTRIBUTORS+1
@@ -8,6 +8,7 @@ Adolfo Ochagavía
88Ahmad Salim Al-Sibahi
99Aistis Raulinaitis
1010Alex Feldman-Crough
11+Alex S. Queiroz e Silva
1112Alexander Berntsen
1213Alexander Shabalin
1314Alyssa Carter
src/Idris/AbsSyntax.hs+3−3
@@ -58,19 +58,19 @@ getObjectFiles :: Codegen -> Idris [FilePath]
5858getObjectFiles tgt = do i <- getIState; return (forCodegen tgt $ idris_objs i)
5959
6060addObjectFile :: Codegen -> FilePath -> Idris ()
61−addObjectFile tgt f = do i <- getIState; putIState $ i { idris_objs = nub $ (tgt, f) : idris_objs i }
61+addObjectFile tgt f = do i <- getIState; putIState $ i { idris_objs = nub $ idris_objs i ++ [(tgt, f)] }
6262
6363getLibs :: Codegen -> Idris [String]
6464getLibs tgt = do i <- getIState; return (forCodegen tgt $ idris_libs i)
6565
6666addLib :: Codegen -> String -> Idris ()
67−addLib tgt f = do i <- getIState; putIState $ i { idris_libs = nub $ (tgt, f) : idris_libs i }
67+addLib tgt f = do i <- getIState; putIState $ i { idris_libs = nub $ idris_libs i ++ [(tgt, f)] }
6868
6969getFlags :: Codegen -> Idris [String]
7070getFlags tgt = do i <- getIState; return (forCodegen tgt $ idris_cgflags i)
7171
7272addFlag :: Codegen -> String -> Idris ()
73−addFlag tgt f = do i <- getIState; putIState $ i { idris_cgflags = nub $ (tgt, f) : idris_cgflags i }
73+addFlag tgt f = do i <- getIState; putIState $ i { idris_cgflags = nub $ idris_cgflags i ++ [(tgt, f)] }
7474
7575addDyLib :: [String] -> Idris (Either DynamicLib String)
7676addDyLib libs = do i <- getIState
test/TestData.hs+2−1
@@ -87,7 +87,8 @@ testFamiliesData = [
8787 [ ( 1, ANY )]),
8888 ("directives", "Directives",
8989 [ ( 1, ANY ),
90− ( 2, ANY )]),
90+ ( 2, ANY ),
91+ ( 3, C_CG )]),
9192 ("disambig", "Disambiguation",
9293 [ ( 2, ANY )]),
9394 ("docs", "Documentation",
test/directives003/directives003.idrnew file+11
@@ -0,0 +1,11 @@
1+module directives003
2+
3+-- names are randomly generated so as to avoid existing names
4+%lib C "nuyahcha"
5+%lib C "mohgiide"
6+%lib C "apeekair"
7+%flag C "-Wl,-leeraimam -Wl,-lrahhahwi -Wl,-lgoocheiv"
8+
9+namespace Main
10+ main : IO ()
11+ main = putStrLn "Hello, World!"
test/directives003/expectednew file+6
@@ -0,0 +1,6 @@
1+nuyahcha
2+mohgiide
3+apeekair
4+eeraimam
5+rahhahwi
6+goocheiv
test/directives003/runnew file+13
@@ -0,0 +1,13 @@
1+#!/usr/bin/env bash
2+
3+# %lib C "nuyahcha"
4+# %lib C "mohgiide"
5+# %lib C "apeekair"
6+# %flag C "-Wl,-leeraimam -Wl,-lrahhahwi -Wl,-lgoocheiv"
7+
8+${IDRIS:-idris} $@ -o directives003 directives003.idr \
9+ | tr ' ,"' '\n' \
10+ | sed 's/-l//' \
11+ | grep -E 'nuyahcha|mohgiide|apeekair|eeraimam|rahhahwi|goocheiv'
12+
13+rm -f directives003 *.ibc