[GHC] #9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.8.2 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- In an attempt to close #4210 the LLVM code generator's mangler was modified in ed67d290e7389bd87a6feea269a0275e0f0f5e2f to rewrite symbol types from `@function` to `@object`. This was done in order to prevent the linker from sending reference through the PLT which breaks info tables. Unfortunately, this mangling was a simple text replacement of `@function` to `@object` in the assembler produced by LLVM and made no attempt to distinguish `.type` directives (which the mangling targets) from other occurrences of the token. As rwbarton unfortunately found out, this means that any occurrences of `"@function"` in user code (e.g. the LLVM backend itself while compiling GHC) will be rewritten to `"@object"` in the produced object. Hilarity ensues. This can be demonstrated by the simple test `main = putStrLn "@function"`, which prints `@object` in the affected releases (7.8.1 through 7.8.3 thusfar). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by bgamari): * cc: rwbarton@… (added) * owner: => bgamari * priority: normal => highest -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: highest | Milestone: Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: D150 | -------------------------------------+------------------------------------- Changes (by bgamari): * differential: => D150 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: 7.8.4 Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9268 | Differential Revisions: Phab:D150 | -------------------------------------+------------------------------------- Changes (by rwbarton): * owner: bgamari => rwbarton * differential: D150 => Phab:D150 * milestone: => 7.8.4 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: rwbarton Type: bug | Status: new Priority: highest | Milestone: 7.8.4 Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9268 | Differential Revisions: Phab:D150 | -------------------------------------+------------------------------------- Comment (by Reid Barton <rwbarton@…>): In [changeset:"5895f2b8ffba72a8393e9f712461e6e5ed7ceced/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="5895f2b8ffba72a8393e9f712461e6e5ed7ceced" LlvmMangler: Be more selective when mangling object types Summary: We previously did a wholesale replace of `%function` to `%object` to mangle object `.type` annotations. This is bad as it can end up replacing appearances of `"%function"` in the user's code. We now look for a proper `.type` keyword before performing the replacement. Thanks to @rwbarton for pointing out the bug. Test Plan: Previously, $ echo 'main = putStrLn "@function"' > test.hs $ ghc -fllvm test.hs $ ./test @object Now, $ echo 'main = putStrLn "@function"' > test.hs $ ghc -fllvm test.hs $ ./test @function Reviewers: rwbarton, austin Reviewed By: rwbarton, austin Subscribers: phaskell, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D150 GHC Trac Issues: #9439 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.8.4 Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9268 | Differential Revisions: Phab:D150 | -------------------------------------+------------------------------------- Changes (by rwbarton): * owner: rwbarton => -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: merge Priority: highest | Milestone: 7.8.4 Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9268 | Differential Revisions: Phab:D150 | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: merge Priority: highest | Milestone: 7.8.4 Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9268 | Differential Revisions: Phab:D150 | -------------------------------------+------------------------------------- Comment (by Austin Seipp <austin@…>): In [changeset:"bbd031134a571c1020945b2548e3fc4795b5047a/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="bbd031134a571c1020945b2548e3fc4795b5047a" Bug #9439: Ensure that stage 0 compiler isn't affected Summary: Bug #9439 will cause miscompilation of GHC's LLVM backend. Here we ensure that an affected compiler isn't used to bootstrap. Test Plan: Attempt to bootstrap GHC with an affected stage 0 compiler. Reviewers: rwbarton, austin Reviewed By: austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D159 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: highest | Milestone: 7.8.4 Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9268 | Differential Revisions: Phab:D150 | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: highest | Milestone: 7.8.4 Component: Compiler | Version: 7.8.2 (LLVM) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9268 | Differential Revisions: Phab:D150 | -------------------------------------+------------------------------------- Comment (by Austin Seipp <austin@…>): In [changeset:"146dd138e2c3b4ec9b211dcbcedf752aeb79d3d1/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="146dd138e2c3b4ec9b211dcbcedf752aeb79d3d1" Only test for bug #9439 when llvm is installed Reviewers: bgamari, austin Reviewed By: austin Subscribers: thomie, carter Differential Revision: https://phabricator.haskell.org/D500 GHC Trac Issues: #9807 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: merge Priority: highest | Milestone: 7.8.4 Component: Compiler (LLVM) | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: 9268 | Differential Revisions: Phab:D150 -------------------------------------+------------------------------------- Changes (by rwbarton): * status: closed => merge Comment: As reported by someone on #ghc, the actual fix 5895f2b8ffba72a8393e9f712461e6e5ed7ceced was never merged, only the subsequent bbd031134a571c1020945b2548e3fc4795b5047a. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: merge Priority: highest | Milestone: 7.8.4 Component: Compiler (LLVM) | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: 9268 | Differential Revisions: Phab:D150 -------------------------------------+------------------------------------- Comment (by Austin Seipp <austin@…>): In [changeset:"1dfab7a8ace5f09f00f8fb695932b4324e88b822/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="1dfab7a8ace5f09f00f8fb695932b4324e88b822" Fix detection of llvm-x.x Summary: Four bug fixes and a little refactoring. * `find -perm \mode` should be `find -perm /mode` (#9697) * `find -regex '$3' should be `find -regex "$3"` (#7661) From `man sh` on my system (Ubuntu 14.04): "Enclosing characters in single quotes preserves the literal meaning of all the characters ..." * LlcCmd and OptCmd should be passed to ghc, using `-pgmlo` and `-pgmlc`, for detection of #9439. * -pgmlo and -pgmlc were undocumented because of an xml tag misplacement. Test Plan: The aclocal.m4 macro has seen about 10 iterations since its inception. Without a testsuite, I can't guarantee this version is bug free either. It's all pretty frustrating. Reviewers: bgamari, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D683 GHC Trac Issues: #9697, #7661, #9439 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: merge Priority: highest | Milestone: 7.8.4 Component: Compiler (LLVM) | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: 9268 | Differential Revisions: Phab:D150 -------------------------------------+------------------------------------- Comment (by Erik de Castro Lopo <erikd@…>): In [changeset:"42448e3757f25735a0a5b5e2b7ee456b5e8b0039/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="42448e3757f25735a0a5b5e2b7ee456b5e8b0039" Do version specific detection of LLVM tools (#10170). The LLVM developers seem to make breaking changes in the LLVM IR language between major releases. As a consumer of the LLVM tools GHC now needs to be locked more tightly to a single version of the LLVM tools. GHC HEAD currently only supports LLVM version 3.6. This commit changes the configure script to look for `llc-3.6` and `opt-3.6` before looking for `llc` and `opt`. If the former are not found, but the later are, check that they actually are version 3.6. At the same time, when detecting known problems with the LLVM tools (ie #9439) test for it using the versions of the LLVM tools retrieved from the bootstrap compiler's settings file. Test Plan: Manual testing. Reviewers: thomie, rwbarton, nomeata, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D745 GHC Trac Issues: #10170 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: highest | Milestone: 7.8.4 Component: Compiler (LLVM) | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: 9268 | Differential Revisions: Phab:D150 -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed Comment: 7.8 is quite old and this is fixed in 7.10. Closing. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: highest | Milestone: 7.8.4 Component: Compiler (LLVM) | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9268 Related Tickets: | Differential Revisions: Phab:D150 -------------------------------------+------------------------------------- Comment (by Thomas Miedema <thomasmiedema@…>): In [changeset:"b40e55954ecdab650d35349cbb93e53df952310e/ghc" b40e559/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="b40e55954ecdab650d35349cbb93e53df952310e" Build system: simplify *-llvm BuildFlavours (#10223) Note that SRC_HC_OPTS are added to every Haskell compilation. So there isn't any need to also add `-fllvm` to GhcStage1HcOpts, GhcStage2HcOpts and GhcLibHcOpts. Small bug fix: make sure we test for -fllvm in SRC_HC_OPTS, to check whether the bootstrap compiler is affected by bug #9439. Reviewed by: austin Differential Revision: https://phabricator.haskell.org/D1188 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:15> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9439: LlvmCodegen: Overzealous mangler incorrectly transforms user code -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: highest | Milestone: 7.8.4 Component: Compiler (LLVM) | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 9268 Related Tickets: | Differential Rev(s): Phab:D150 -------------------------------------+------------------------------------- Comment (by Erik de Castro Lopo <erikd@…>): In [changeset:"6fe235543de7ea4319269f164ea444e4af68f759/ghc" 6fe2355/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="6fe235543de7ea4319269f164ea444e4af68f759" configure.ac: Remove checks for bug 9439 Bug #9439 only affects some ghc 7.8 versions of the compiler and since git HEAD no longer builds with ghc-7.8 we can drop this check. Test Plan: Works here! Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2427 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9439#comment:16> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC