Bug 234671 - clang faults while compiling new GlusterFS source code
Summary: clang faults while compiling new GlusterFS source code
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-06 21:02 UTC by andrew
Modified: 2019-12-11 02:13 UTC (History)
3 users (show)

See Also:
koobs: mfc-stable12+
koobs: mfc-stable11+


Attachments
Compiler diagnostic data: preprocessed source (223.46 KB, application/x-xz)
2019-01-06 21:04 UTC, andrew
no flags Details
Compiler diagnostic data: run script (4.21 KB, application/x-shellscript)
2019-01-06 21:04 UTC, andrew
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description andrew 2019-01-06 21:02:35 UTC
Compiler fails with 'fatal error: error in backend: A @@ version cannot be undefined'.
Comment 1 andrew 2019-01-06 21:04:02 UTC
Created attachment 200846 [details]
Compiler diagnostic data: preprocessed source
Comment 2 andrew 2019-01-06 21:04:32 UTC
Created attachment 200847 [details]
Compiler diagnostic data: run script
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2019-01-13 22:34:45 UTC
I can reproduce this, and it looks almost the same as <https://bugs.llvm.org/show_bug.cgi?id=39270>.

Mostly minimized:

/* clang -cc1 -triple x86_64-- -emit-obj glfs-min.c */

#define STR(str) #str

#define GFAPI_SYMVER_PRIVATE_DEFAULT(fn, ver) \
        asm(".symver priv_"STR(fn)", "STR(fn)"@@GFAPI_PRIVATE_"STR(ver))

GFAPI_SYMVER_PRIVATE_DEFAULT(foo, 1.0);

Minimized even more:

/* clang -cc1 -triple x86_64-- -emit-obj glfs-min.c */
asm(".symver a,b@@c");

The upstream bug report is sitting there since 2018-10-13 without any activity, I'll see if I can poke somebody.
Comment 4 commit-hook freebsd_committer freebsd_triage 2019-02-13 20:14:43 UTC
A commit references this bug:

Author: dim
Date: Wed Feb 13 20:13:40 UTC 2019
New revision: 344112
URL: https://svnweb.freebsd.org/changeset/base/344112

Log:
  Pull in r353907 from upstream llvm trunk (by Reid Kleckner):

    [MC] Make symbol version errors non-fatal

    We stil don't have a source location, which is pretty lame, but at
    least we won't tell the user to file a clang bug report anymore.

    Fixes PR40712

  This will make errors for symbols with @@ versions that are not defined
  non-fatal.  For example:

    void f(void)
    {
      __asm__(".symver foo,bar@@baz");
    }

  will now result in:

    error: versioned symbol bar@@baz must be defined

  instead of clang crashing with a diagnostic report.

  PR:		234671
  Upstream PR:	https://bugs.llvm.org/show_bug.cgi?id=40712
  MFC after:	3 days

Changes:
  head/contrib/llvm/lib/MC/ELFObjectWriter.cpp
Comment 5 commit-hook freebsd_committer freebsd_triage 2019-02-16 19:50:03 UTC
A commit references this bug:

Author: dim
Date: Sat Feb 16 19:49:13 UTC 2019
New revision: 344217
URL: https://svnweb.freebsd.org/changeset/base/344217

Log:
  MFC r344112:

  Pull in r353907 from upstream llvm trunk (by Reid Kleckner):

    [MC] Make symbol version errors non-fatal

    We stil don't have a source location, which is pretty lame, but at
    least we won't tell the user to file a clang bug report anymore.

    Fixes PR40712

  This will make errors for symbols with @@ versions that are not defined
  non-fatal.  For example:

    void f(void)
    {
      __asm__(".symver foo,bar@@baz");
    }

  will now result in:

    error: versioned symbol bar@@baz must be defined

  instead of clang crashing with a diagnostic report.

  PR:		234671
  Upstream PR:	https://bugs.llvm.org/show_bug.cgi?id=40712

Changes:
_U  stable/11/
  stable/11/contrib/llvm/lib/MC/ELFObjectWriter.cpp
_U  stable/12/
  stable/12/contrib/llvm/lib/MC/ELFObjectWriter.cpp
Comment 6 Dimitry Andric freebsd_committer freebsd_triage 2019-02-16 20:46:31 UTC
After merging the upstream fixes, clang won't crash anymore with a fatal error.  It still will refuse to compile the glfs.c file though, now with:

error: versioned symbol glfs_upcall_register@@GFAPI_3.13.0 must be defined
error: versioned symbol glfs_upcall_unregister@@GFAPI_3.13.0 must be defined
2 errors generated.

Indeed, this is an error in the code, which seems to have been fixed in this upstream commit (together with a lot of other symbol breakage):

https://github.com/gluster/glusterfs/commit/b4ce5e090dee2afc9ed0c86456a54f76a2bb6563

Can you try applying that, or at least parts of it?  Alternatively, a minimal fix is:

--- a/glfs.c       2019-01-10 08:57:50.000000000 +0100
+++ b/glfs.c       2019-02-16 21:45:03.999966000 +0100
@@ -48952,7 +48952,7 @@
 GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_sysrq, 3.10.0);

 int
-glfs_upcall_register (struct glfs *fs, uint32_t event_list,
+pub_glfs_upcall_register (struct glfs *fs, uint32_t event_list,
                       glfs_upcall_cbk cbk, void *data)
 {
         int ret = 0;
@@ -49003,7 +49003,7 @@
 }
 GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_upcall_register, 3.13.0);

-int glfs_upcall_unregister (struct glfs *fs, uint32_t event_list)
+int pub_glfs_upcall_unregister (struct glfs *fs, uint32_t event_list)
 {
         int ret = 0;
         /* list of supported upcall events */