Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#10687 closed bug (fixed)

Clang 3.6 fails with -g due to .file directive order

Reported by: scpmw Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


On Mac Os X, compiling with -g will sometimes fail with an error like follows:

/var/folders/yt/bmbchswn57nbmz1l67btd6p00000gn/T/ghc27418_0/ghc_1.s:6573:7: error:
     error: unassigned file number in '.loc' directive
            .loc 7 106 17 /* cast */

Which refers to the following code:

	.file 7 "libraries/base/Data/Typeable.hs"
	.file 6 "libraries/ghc-prim/GHC/Classes.hs"
	.loc 7 106 17 /* cast */

So the file number is clearly assigned, we are just not assigning them "in order". This is okay for most compilers, but Clang 3.6 seems to disagree. The attached patch changes the code so .file directives are always generated in order.

Could try to produce a testcase if required - it would be rather easy to check that .file directives appear in order in a given assembly file.

Attachments (1)

file-order-clang-fix.patch (1.5 KB) - added by scpmw 2 years ago.
Proposed patch

Download all attachments as: .zip

Change History (6)

Changed 2 years ago by scpmw

Attachment: file-order-clang-fix.patch added

Proposed patch

comment:1 Changed 2 years ago by thomie

Status: newpatch

comment:2 Changed 2 years ago by Ben Gamari <ben@…>

In 36811bfd/ghc:

AsmCodeGen: Ensure LLVM .line directives are sorted

Apparently some Clang 3.6 expects these to be sorted.

Patch due to Peter Wortmann.

Fixes #10687.

comment:3 Changed 2 years ago by bgamari

Status: patchmerge

comment:4 Changed 2 years ago by bgamari

Resolution: fixed
Status: mergeclosed

comment:5 Changed 2 years ago by bgamari

Fixed and merged to ghc-7.10 as 36811bfd3bd981d3cd3cc7280e1a815ba1ed42e9.

Note: See TracTickets for help on using tickets.