Bug 248736 - devel/json-glib: Fix build with clang 11
Summary: devel/json-glib: Fix build with clang 11
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Niclas Zeising
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-18 21:11 UTC by Dimitry Andric
Modified: 2020-09-23 14:54 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (gnome)


Attachments
Fix build with -fno-common (clang 11 and gcc 10) (1.02 KB, patch)
2020-08-18 21:11 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 Dimitry Andric freebsd_committer freebsd_triage 2020-08-18 21:11:30 UTC
Created attachment 217321 [details]
Fix build with -fno-common (clang 11 and gcc 10)

In base r364284, I imported clang 11 into head. Like gcc 10, it now defaults to -fno-common, meaning that duplicated global symbols will most likely lead to link errors. Here is a patch to fix this port's duplicated global symbols.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2020-08-18 21:16:44 UTC
Sorry, the summary and description were not correct. In case of json-glib, it was a new clang 11 -Werror warning:

../json-glib/json-scanner.c:928:13: error: cast to smaller integer type 'GTokenType' from 'gpointer' (aka 'void *') [-Werror,-Wvoid-pointer-to-enum-cast]
        *token_p = (GTokenType) value_p->v_symbol;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is because v_symbol is a pointer and GTokenType is an enum (so int-like). Glib provides the GPOINTER_TO_INT macro for this purpose.
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2020-08-18 21:17:07 UTC
Sorry, the summary and description were not correct. In case of json-glib, it was a new clang 11 -Werror warning:

../json-glib/json-scanner.c:928:13: error: cast to smaller integer type 'GTokenType' from 'gpointer' (aka 'void *') [-Werror,-Wvoid-pointer-to-enum-cast]
        *token_p = (GTokenType) value_p->v_symbol;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is because v_symbol is a pointer and GTokenType is an enum (so int-like). Glib provides the GPOINTER_TO_INT macro for this purpose.
Comment 3 Jan Beich freebsd_committer freebsd_triage 2020-08-19 03:51:23 UTC
I've submitted upstream as https://gitlab.gnome.org/GNOME/json-glib/-/merge_requests/29
Comment 4 Niclas Zeising freebsd_committer freebsd_triage 2020-08-22 09:38:18 UTC
Committed, awaiting merge.
Comment 5 commit-hook freebsd_committer freebsd_triage 2020-08-22 09:38:45 UTC
A commit references this bug:

Author: zeising
Date: Sat Aug 22 09:37:47 UTC 2020
New revision: 545754
URL: https://svnweb.freebsd.org/changeset/ports/545754

Log:
  devel/json-glib: Fix build with llvm 11

  Fix the build of devel/json-glib with llvm 11.
  llvm 11 introduced a new warning relating to how to cast between void * and
  enums, which json-glib are stumbling over.

  PR:		248736
  Submitted by:	dim
  MFH:		2020Q3

Changes:
  head/devel/json-glib/files/
  head/devel/json-glib/files/patch-json-glib_json-scanner.c