#19159: Compilation fails for macOS target using clang 12

46 views
Skip to first unread message

wxTrac

unread,
Apr 24, 2021, 5:04:53 PM4/24/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
---------------------+-------------------------
Reporter: ancwrd1 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Keywords: | Blocked By:
Blocking: | Patch: 0
---------------------+-------------------------
Trying to build wxWidgets for macOS target using clang 12, compilation
fails with the following errors:

{{{
In file included from /wxWidgets/src/osx/cocoa/appprogress.mm:11:
In file included from /wxWidgets/include/wx/osx/private.h:4:
In file included from /wxWidgets/include/wx/osx/core/private.h:20:
/wxWidgets/include/wx/osx/core/cfstring.h:46:71: error: ObjectiveC object
of type 'WX_NSString' (aka 'NSString *') is bridged to 'CFStringRef' (aka
'const __CFString *'), which is not valid CF object
: wxCFRef< CFStringRef >((WX_OSX_BRIDGE_RETAINED CFStringRef) ref)
^
../SDK/MacOSX11.1.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:463:1:
note: declared here
typedef const struct CF_BRIDGED_TYPE(NSString) __CFString * CFStringRef;
^
In file included from /wxWidgets/src/osx/cocoa/appprogress.mm:11:
In file included from /wxWidgets/include/wx/osx/private.h:4:
In file included from /wxWidgets/include/wx/osx/core/private.h:20:
/wxWidgets/include/wx/osx/core/cfstring.h:74:72: error: CF object of type
'CFStringRef' (aka 'const __CFString *') is bridged to 'NSMutableString',
which is not an Objective-C class
WX_NSString AsNSString() const { return (WX_OSX_BRIDGE
WX_NSString)(CFStringRef) *this; }
^
../SDK/MacOSX11.1.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:463:1:
note: declared here
typedef const struct CF_BRIDGED_TYPE(NSString) __CFString * CFStringRef;
^
In file included from /wxWidgets/src/osx/cocoa/appprogress.mm:11:
In file included from /wxWidgets/include/wx/osx/private.h:4:
In file included from /wxWidgets/include/wx/osx/core/private.h:20:
/wxWidgets/include/wx/osx/core/cfstring.h:99:60: error: ObjectiveC object
of type 'NSString *' is bridged to 'CFStringRef' (aka 'const __CFString
*'), which is not valid CF object
return wxCFStringRefFromGet((WX_OSX_BRIDGE CFStringRef)p);
^
../SDK/MacOSX11.1.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:463:1:
note: declared here
typedef const struct CF_BRIDGED_TYPE(NSString) __CFString * CFStringRef;
}}}

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159>

wxTrac

unread,
Apr 24, 2021, 6:00:57 PM4/24/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------

Comment (by vadz):

Is this Apple clang or normal clang 12? In any case, I'm afraid I have no
idea what to do about this, i.e. why does it think these are not valid CF
objects/classes. Any ideas would be welcome.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:1>

wxTrac

unread,
Apr 25, 2021, 5:35:03 AM4/25/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------
Changes (by ancwrd1):

* cc: dmitry@… (added)


Comment:

This is normal clang 12, might be related to a compiler configuration. I
will check.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:2>

wxTrac

unread,
Apr 25, 2021, 3:01:59 PM4/25/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------

Comment (by csomor):

Funny, I had this once, somehow headers got messed up, the SDK had certain
files I could not load, after reinstalling Xcode I could not reproduce it
anymore, so I didn't investigate it further..

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:3>

wxTrac

unread,
Apr 29, 2021, 4:25:14 PM4/29/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------
Changes (by ancwrd1):

* cc: dmitry@… (removed)


Comment:

> Any ideas would be welcome

Adding {{{ #import <Foundation/Foundation.h>" }}} on top of the
appprogress.mm file fixes the compilation issue.

I'd like to point out that this only applies to stock clang installed via
homebrew (or when cross-compiling wxwidgets from a different OS). With
Apple Clang this issue does not happen.

If I add this import to the header file (e.g. osx/core/private.h) it
compiles but with the "bridge-cast" warnings:

{{{
/wxWidgets/include/wx/osx/core/cfstring.h:46:71: warning: 'NSString'
cannot bridge to 'CFStringRef' (aka 'const __CFString *') [-Wbridge-cast]
: wxCFRef< CFStringRef >((WX_OSX_BRIDGE_RETAINED CFStringRef)
(NSString*)ref)
}}}

If I add it on top of the mm file it compiles without warnings.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:4>

wxTrac

unread,
Apr 30, 2021, 2:41:46 AM4/30/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner: csomor
Type: defect | Status: accepted
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------
Changes (by csomor):

* status: new => accepted
* owner: => csomor


Comment:

I've compared the different CFBase.h headers, where the bridge info is
located.

Up to SDK 10.9 types like CFStringRef were declared like we do in defs.h,
later they got the 'objc_bridge' attribute added, also when compiling
without ARC our WX_OSX_BRIDGE resolves to empty.

@ancwrd1 are you doing an ARC enabled build by chance against your code ?

since we are now mandating SDK 10.11 as minimum, I don't see a problem
adding all the missing info to our defs.h

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:5>

wxTrac

unread,
Apr 30, 2021, 2:55:18 AM4/30/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner: csomor
Type: defect | Status: accepted
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------
Changes (by ancwrd1):

* cc: dmitry@… (added)


Comment:

No, it's without ARC, I actually tried with -fobjc-arc but it gave a whole
set of other issues (mostly related to wrong Release calls).

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:6>

wxTrac

unread,
Apr 30, 2021, 6:33:13 AM4/30/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner: csomor
Type: defect | Status: infoneeded
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------
Changes (by csomor):

* status: accepted => infoneeded


Comment:

could you please test with
https://github.com/wxWidgets/wxWidgets/pull/2354

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:7>

wxTrac

unread,
Apr 30, 2021, 8:19:03 AM4/30/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner: csomor
Type: defect | Status: accepted
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------
Changes (by ancwrd1):

* cc: dmitry@… (removed)
* status: infoneeded => accepted


Comment:

Confirmed working, compilation finished without errors or warnings. Thanks
for a quick fix.

--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:8>

wxTrac

unread,
Apr 30, 2021, 12:09:02 PM4/30/21
to wx-...@googlegroups.com
#19159: Compilation fails for macOS target using clang 12
----------------------+------------------------
Reporter: ancwrd1 | Owner: csomor
Type: defect | Status: closed
Priority: normal | Milestone:
Component: wxOSX | Version: dev-latest
Resolution: fixed | Keywords:
Blocked By: | Blocking:
Patch: 0 |
----------------------+------------------------
Changes (by csomor):

* status: accepted => closed
* resolution: => fixed


--
Ticket URL: <https://trac.wxwidgets.org/ticket/19159#comment:9>
Reply all
Reply to author
Forward
0 new messages