Bug 206376

Summary: emulators/mednafen: Fix build with clang 3.8.0 or recent versions of GCC
Product: Ports & Packages Reporter: Dimitry Andric <dim>
Component: Individual Port(s)Assignee: Jose Alonso Cardenas Marquez <acm>
Status: Closed FIXED    
Severity: Affects Some People CC: acm, mi
Priority: --- Keywords: patch, patch-ready
Version: LatestFlags: bugzilla: maintainer-feedback? (acm)
koobs: merge-quarterly?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Use local asm labels to prevent problems with unrolling
none
Upgrade emulators/mednafen to 0.9.38.7 mi: maintainer-approval? (acm)

Description Dimitry Andric freebsd_committer freebsd_triage 2016-01-18 18:54:08 UTC
Created attachment 165773 [details]
Use local asm labels to prevent problems with unrolling

During the exp-run in bug 206074, it was found that emulators/mednafen gives errors with a recent clang 3.8.0 snapshot [1]:

    OwlResampler.cpp:447:39: error: invalid symbol redefinition
    "movups  0(%%" X86_REGC "di), %%xmm0\n\t"
                                      ^
    <inline asm>:7:2: note: instantiated into assembly here
            SSE_Loop:
            ^

This is because a named asm label should not be used in an inline function.  If the function is used while unrolling a loop, as in this case, it will lead to duplicated asm labels.  Note that gcc 4.7 and higher also complain similarly, when used with optimization.

The fix is to use a local label, "1:", and jump to it using "jnz 1b".

[1] http://package18.nyi.freebsd.org/data/headamd64PR206074-default/2016-01-15_15h26m58s/logs/errors/libxul-38.5.2.log
Comment 1 Mikhail Teterin freebsd_committer freebsd_triage 2016-02-19 05:07:24 UTC
Created attachment 167165 [details]
Upgrade emulators/mednafen to 0.9.38.7

After upgrading the port to the currently-latest version 0.9.38.7 I was able to build it using clang38 without having to patch the assembly-code.

Not sure, if this really obsoletes Dimitry's patch...
Comment 2 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2016-05-05 13:43:26 UTC
emulators/mednafen was updated to 0.9.38.7. Thanks!