{"action":"created","issue":{"url":"https://api.github.com/repos/haskell/cabal/issues/5254","repository_url":"https://api.github.com/repos/haskell/cabal","labels_url":"https://api.github.com/repos/haskell/cabal/issues/5254/labels{/name}","comments_url":"https://api.github.com/repos/haskell/cabal/issues/5254/comments","events_url":"https://api.github.com/repos/haskell/cabal/issues/5254/events","html_url":"https://github.com/haskell/cabal/issues/5254","id":311553723,"number":5254,"title":"Linker error on Windows with chocolate","user":{"login":"Mikolaj","id":281893,"avatar_url":"https://avatars3.githubusercontent.com/u/281893?v=4","gravatar_id":"","url":"https://api.github.com/users/Mikolaj","html_url":"https://github.com/Mikolaj","followers_url":"https://api.github.com/users/Mikolaj/followers","following_url":"https://api.github.com/users/Mikolaj/following{/other_user}","gists_url":"https://api.github.com/users/Mikolaj/gists{/gist_id}","starred_url":"https://api.github.com/users/Mikolaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mikolaj/subscriptions","organizations_url":"https://api.github.com/users/Mikolaj/orgs","repos_url":"https://api.github.com/users/Mikolaj/repos","events_url":"https://api.github.com/users/Mikolaj/events{/privacy}","received_events_url":"https://api.github.com/users/Mikolaj/received_events","type":"User","site_admin":false},"labels":[{"id":5625689,"url":"https://api.github.com/repos/haskell/cabal/labels/platform:%20windows","name":"platform: windows","color":"f9d0c4","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-04-05T10:22:22Z","updated_at":"2018-04-12T22:45:52Z","closed_at":null,"author_association":"MEMBER","body":"Here is the log exhibiting the linker failure with cabal 2.2.0.0: https://ci.appveyor.com/project/Mikolaj/allure/build/1.0.148\r\n\r\n```\r\nLinking dist\\build\\Allure\\Allure.exe ...\r\nWarning: resolving _GetModuleFileNameW by linking to _GetModuleFileNameW@12\r\nUse --enable-stdcall-fixup to disable these warnings\r\nUse --disable-stdcall-fixup to disable these fixups\r\n    `_GetModuleFileNameW' referenced in section `.text' of dist\\build\\Allure\\Allure-tmp\\Paths_Allure.o: defined in discarded section `.text' of C:/ProgramData/chocolatey/lib/ghc/tools/ghc-8.2.2/mingw/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a(dghgds00535.o)\r\ncollect2.exe: error: ld returned 1 exit status\r\n```\r\n\r\nAnd the same project succeeds after downgrading cabal to 2.0.0.1: https://ci.appveyor.com/project/Mikolaj/allure/build/1.0.149\r\n\r\nI both cases, initial 64bit build succeed fine, only the subsequent 32bit build fails (with the new cabal version).\r\n\r\nI tried `--enable-stdcall-fixup`, which made the warnings disappear, but the error remain. Then I tried `--disable-stdcall-fixup` and I got a different error (as before, only in 32bit build, https://ci.appveyor.com/project/Mikolaj/allure/build/1.0.150):\r\n\r\n```\r\nLinking dist\\build\\Allure\\Allure.exe ...\r\ndist\\build\\Allure\\Allure-tmp\\Paths_Allure.o:fake:(.text+0xe65): undefined reference to `GetModuleFileNameW'\r\ncollect2.exe: error: ld returned 1 exit status\r\n```\r\n\r\nWhen comparing the logs, nothing strikes me, except that only the 64bit compilation (the one that doesn't fail) shows the warning (but only with the old cabal):\r\n\r\n```\r\ndist\\build\\Allure\\autogen\\Paths_Allure.hs:73:1: warning: [-Wunsupported-calling-conventions]\r\n    * the 'stdcall' calling convention is unsupported on this platform,\r\n      treating as ccall\r\n    * When checking declaration:\r\n        foreign import stdcall unsafe \"windows.h GetModuleFileNameW\" c_GetModuleFileName\r\n          :: Ptr () -> CWString -> Int32 -> IO Int32\r\n   |\r\n73 | foreign import stdcall unsafe \"windows.h GetModuleFileNameW\"\r\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...\r\n```\r\n\r\n(So it seems as if old cabal had the stdcall problem only on 64bit, but the fixes changed also how 32bit builds work and broke them.)\r\n\r\nAlso, the log shows some new chocolatey Windows shims are present in the new chocolatey cabal package. But they probably only add the exes to path, so should be benign. \r\n\r\nThe error does not appear if the exe is in the same cabal package as the lib: https://ci.appveyor.com/project/Mikolaj/lambdahack/build/1.0.428\r\n\r\nSome vaguely related links:\r\n\r\nhttps://mcuoneclipse.com/2017/11/12/solving-problem-with-gnu-linker-and-referenced-in-section-defined-in-discarded-section-error-message\r\nhttps://stackoverflow.com/questions/31085538/function-referenced-in-section-text-of-defined-in-discarded-section-te\r\nhttps://ghc.haskell.org/trac/ghc/ticket/9524\r\nhttps://ghc.haskell.org/trac/ghc/ticket/14300\r\n"},"comment":{"url":"https://api.github.com/repos/haskell/cabal/issues/comments/380967082","html_url":"https://github.com/haskell/cabal/issues/5254#issuecomment-380967082","issue_url":"https://api.github.com/repos/haskell/cabal/issues/5254","id":380967082,"user":{"login":"Mikolaj","id":281893,"avatar_url":"https://avatars3.githubusercontent.com/u/281893?v=4","gravatar_id":"","url":"https://api.github.com/users/Mikolaj","html_url":"https://github.com/Mikolaj","followers_url":"https://api.github.com/users/Mikolaj/followers","following_url":"https://api.github.com/users/Mikolaj/following{/other_user}","gists_url":"https://api.github.com/users/Mikolaj/gists{/gist_id}","starred_url":"https://api.github.com/users/Mikolaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mikolaj/subscriptions","organizations_url":"https://api.github.com/users/Mikolaj/orgs","repos_url":"https://api.github.com/users/Mikolaj/repos","events_url":"https://api.github.com/users/Mikolaj/events{/privacy}","received_events_url":"https://api.github.com/users/Mikolaj/received_events","type":"User","site_admin":false},"created_at":"2018-04-12T22:45:52Z","updated_at":"2018-04-12T22:45:52Z","author_association":"MEMBER","body":"Indeed, it takes the arch from `System.Info` at compile time of cabal exe: https://github.com/haskell/cabal/blob/76bafc11e53390b9adfd1b3a8ea907d0adaa45a6/Cabal/Distribution/System.hs#L218"}}
{"actor":{"display_login":"Mikolaj"}}