packages feed

clr-win-linker (empty) → 0.1.0.0

raw patch · 5 files changed

+108/−0 lines, 5 filesdep +basedep +directorydep +pipessetup-changed

Dependencies added: base, directory, pipes, pipes-safe, process

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Tim Matthews (c) 2017++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Tim Matthews nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,17 @@+This package provides small utility to backport GHC bug fix [#12186](https://ghc.haskell.org/trac/ghc/ticket/12186) for GHC versions < 8.2++It works by being specified as the linker, where it will simply do a find and replace on the supplied linker args before passing the result on to the real linker.++To build & install, run the following:++    stack install clr-win-linker++Which will copy the resulting executable to the path, usually 'C:\Users\<name>\AppData\Roaming\local\bin'++Then specify as the linker when building other packages like so:++    stack build --ghc-options="-pgml clr-win-linker"++And the resulting executables should then get past ghc issue #12186:++    stack exec clr-test-app
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ clr-win-linker.cabal view
@@ -0,0 +1,20 @@+name:                clr-win-linker+version:             0.1.0.0+synopsis:            A GHC linker wrapper tool to workaround a GHC >8.2 bug+description:         Please see README.md+homepage:            https://gitlab.com/tim-m89/clr-haskell/tree/master/utils/clr-win-linker+license:             BSD3+license-file:        LICENSE+author:              Tim Matthews+maintainer:          tim.matthews7@gmail.com+copyright:           2017 Tim Matthews+category:            Language, FFI, CLR, .NET+build-type:          Simple+cabal-version:       >=1.10+extra-source-files:  README.md++executable clr-win-linker+  hs-source-dirs:      src+  main-is:             Main.hs+  default-language:    Haskell2010+  build-depends:       base >= 4.7 && < 5, process, pipes, pipes-safe, directory
+ src/Main.hs view
@@ -0,0 +1,39 @@+module Main where++import Control.Monad+import Data.List+import System.Environment+import System.Process+import System.IO+import System.Directory+import Pipes+import Pipes.Safe+import qualified Pipes.Safe.Prelude as SP+import Pipes.Prelude++runLinker :: [String] -> IO ()+runLinker args = callProcess "gcc" args++modifyLinkerArgs :: Pipe String String (SafeT IO) ()+modifyLinkerArgs = do+  x <- await+  if x == "\"-Xlinker\""+    then do+      y <- await+      if y == "\"--stack=0x800000,0x800000\""+        then yield "\"-fstack-check\""+      else yield x >> yield y+    else yield x+  modifyLinkerArgs++main :: IO ()+main = do+  args <- getArgs+  case args of+    (  []  ) -> error "No args"+    (x : xs) -> do+      let linkFileOrig = tail x+      let linkFileNew  = linkFileOrig ++ "-temp"+      runSafeT $ runEffect $ SP.readFile linkFileOrig >-> modifyLinkerArgs >-> SP.writeFile linkFileNew+      renameFile linkFileNew linkFileOrig+      runLinker args