Bug 216154 - graphics/svgalib: fails to build with clang 4.0 (1439 ports skipped)
Summary: graphics/svgalib: fails to build with clang 4.0 (1439 ports skipped)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Only Me
Assignee: Jan Beich
URL:
Keywords: needs-patch
Depends on:
Blocks: 216008
  Show dependency treegraph
 
Reported: 2017-01-16 22:57 UTC by Jan Beich
Modified: 2017-02-01 12:54 UTC (History)
1 user (show)

See Also:


Attachments
workaround (691 bytes, patch)
2017-01-20 11:29 UTC, Jan Beich
no flags Details | Diff
Remove unnecessary clobbers from inline asm statements (1.06 KB, patch)
2017-01-21 14:16 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2017-01-16 22:57:07 UTC
In file included from gl/grlib.c:7:
gl/inlstring.h:71:9: error: asm-specifier for input or output variable conflicts with asm clobber list
  :         "cx", "di");
            ^
gl/inlstring.h:281:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                         :"ax", "0", "1", "2");
                                     ^
gl/inlstring.h:297:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                         :"ax", "0", "1", "2");
                                     ^
gl/inlstring.h:314:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                         :"ax", "0", "1", "2");
                                     ^

build log: http://sprunge.us/hKCH
Comment 1 Jan Beich freebsd_committer 2017-01-16 22:57:51 UTC
Another way to reproduce:

  $ pkg install llvm-devel
  $ make clean all CC='clang-devel -m32' ARCH=i386

except devel/llvm-devel is too old to have the issue.
Comment 2 Jan Beich freebsd_committer 2017-01-19 14:43:52 UTC
https://reviews.llvm.org/D15075 likely broke it but I have no clue about the fix other than switch to GCC or disable inline asm.
Comment 3 Jan Beich freebsd_committer 2017-01-20 11:29:09 UTC
Created attachment 179132 [details]
workaround
Comment 4 Dimitry Andric freebsd_committer 2017-01-21 14:16:52 UTC
Created attachment 179183 [details]
Remove unnecessary clobbers from inline asm statements

Here is a patch that gets rid of the unnecessary clobbers from the inline assembly statements.  (It seems a previous maintainer, marked with **rjr**, has already done so for a number of other clobbers, but has not completed the job.)

Tested to build with both clang and gcc.
Comment 5 Jan Beich freebsd_committer 2017-01-21 20:12:42 UTC
Comment on attachment 179183 [details]
Remove unnecessary clobbers from inline asm statements

Looks OK but I wonder if the code is actually used anywhere. Maintainer approval can probably be replaced with "portmgr blanket" here.

+-			 :"ax", "0", "1", "2");
++			 :"ax");
[...]
+-			 :"ax", "0", "1", "2");
++			 :"ax");
[...]
+-			 :"ax", "0", "1", "2");
++			 :"ax");

"0" doesn't conflict according to Clang.
Comment 6 Dimitry Andric freebsd_committer 2017-01-21 23:16:43 UTC
(In reply to Jan Beich (mail not working) from comment #5)
> Comment on attachment 179183 [details]
> Remove unnecessary clobbers from inline asm statements
> 
> Looks OK but I wonder if the code is actually used anywhere.

Indeed, and on modern CPUs using "rep stosb" actually performs less than a while loop, so these routines are not really needed anymore.  That said, this is old code anyway, it is probably best to change as little as possible.


> +-			 :"ax", "0", "1", "2");
> ++			 :"ax");
> [...]
> +-			 :"ax", "0", "1", "2");
> ++			 :"ax");
> [...]
> +-			 :"ax", "0", "1", "2");
> ++			 :"ax");
> 
> "0" doesn't conflict according to Clang.

That is actually strange, since the idea is that input or output registers do not have to appear in the clobber lists at all.  Maybe this is just a case missed by clang, I will check with upstream.
Comment 7 Jan Beich freebsd_committer 2017-01-31 03:18:27 UTC
(In reply to Dimitry Andric from comment #6)
> ... I will check with upstream.

Any news?
Comment 8 Dimitry Andric freebsd_committer 2017-01-31 20:41:35 UTC
(In reply to Jan Beich (mail not working) from comment #7)
> (In reply to Dimitry Andric from comment #6)
> > ... I will check with upstream.
> 
> Any news?

Finally unslacked, and sent a mail to the original implementers of the error message, and CC'd the cfe-commits mailing list.

For now, we can just apply the patch though, then at least svgalib is unborked.
Comment 9 commit-hook freebsd_committer 2017-02-01 05:24:58 UTC
A commit references this bug:

Author: jbeich
Date: Wed Feb  1 05:24:35 UTC 2017
New revision: 432966
URL: https://svnweb.freebsd.org/changeset/ports/432966

Log:
  graphics/svgalib: unbreak with clang 4.0

  In file included from gl/grlib.c:7:
  gl/inlstring.h:71:9: error: asm-specifier for input or output variable conflicts with asm clobber list
    :         "cx", "di");
              ^
  gl/inlstring.h:281:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                           :"ax", "0", "1", "2");
                                       ^
  gl/inlstring.h:297:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                           :"ax", "0", "1", "2");
                                       ^
  gl/inlstring.h:314:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                           :"ax", "0", "1", "2");
                                       ^

  PR:		216154
  Reported by:	antoine (via exp-run)
  Submitted by:	dim
  Approved by:	portmgr blanket

Changes:
  head/graphics/svgalib/files/patch-gl-inlstring.h
Comment 10 commit-hook freebsd_committer 2017-02-01 12:54:18 UTC
A commit references this bug:

Author: jbeich
Date: Wed Feb  1 12:53:43 UTC 2017
New revision: 433026
URL: https://svnweb.freebsd.org/changeset/ports/433026

Log:
  MFH: r432966

  graphics/svgalib: unbreak with clang 4.0

  In file included from gl/grlib.c:7:
  gl/inlstring.h:71:9: error: asm-specifier for input or output variable conflicts with asm clobber list
    :         "cx", "di");
              ^
  gl/inlstring.h:281:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                           :"ax", "0", "1", "2");
                                       ^
  gl/inlstring.h:297:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                           :"ax", "0", "1", "2");
                                       ^
  gl/inlstring.h:314:17: error: asm-specifier for input or output variable conflicts with asm clobber list
                           :"ax", "0", "1", "2");
                                       ^

  PR:		216154
  Reported by:	antoine (via exp-run)
  Submitted by:	dim
  Approved by:	portmgr blanket
  Approved by:	ports-secteam blanket

Changes:
_U  branches/2017Q1/
  branches/2017Q1/graphics/svgalib/files/patch-gl-inlstring.h