On 19 Jun 2015, at 14:41, Hans Petter Selasky <h...@selasky.org> wrote:
> 
> On 06/19/15 14:54, David Chisnall wrote:
>> I definitely know of people building out-of-ports programs on FreeBSD whose 
>> code you have just broken (including myself,
> > though I do Objective-C stuff on 10, so haven’t yet encountered the 
> > breakage).
> 
> Hi David,
> 
> r268137 has been in 11-current for a long time (11 months) and was MFC'ed to 
> 10-stable not long ago. 

We have not yet done a release from 10 with this breakage, so I’ve not yet seen 
it in the wild.  Most people doing Objective-C development do not develop on 
FreeBSD -HEAD.  The majority develop on OS X and port to FreeBSD releases.  I 
am anxious to get this fixed before the next 10.x release is out so that we are 
not shipping something that is going to force people wanting to ship 
Objective-C code to have to have FreeBSD-specific work-arounds for the next few 
years.

> I understand that including "sys/cdefs.h" breaks objective C-code in the 
> kernel, but we don't have any such code, do we?

You fundamentally misunderstand what cdefs.h is.  It is not a kernel header, it 
is the header that provides all of the definitions required for all system 
headers.  All libc headers expect cdefs.h to be included (either directly or 
indirectly) before anything else in the file.

> Multiple systems are defining __weak for C and C++ :
> 
> Linux:
>> include/linux/compiler-gcc.h:
> #define __weak                                __attribute__((weak))
> 
> NetBSD:
> > sys/cdefs_elf.h
> #define __weak  __attribute__((__weak__))
> 
> FreeBSD:
> > sys/cdefs.h
> #define       __weak  __attribute__((__weak__))

NetBSD is the only system that I’m aware of that has actually shipped this, and 
it broke a lot of things.

Spot the odd one out:

$ cat tmp.m
#include <stdio.h>
__weak id x;
# FreeBSD 10.1:
$ cc -E tmp.m -fobjc-arc | tail -1
__attribute__((objc_ownership(weak))) id x;
# Linux
$ clang -E tmp.m -fobjc-runtime=gnustep-1.7 -fobjc-arc | tail -1
__attribute__((objc_ownership(weak))) id x;
# FreeBSD Head:
$ cc -E tmp.m -fobjc-arc | tail -1
__attribute__((__weak__)) id x;

The worst thing about this is that you have broken it so that it silently does 
the wrong thing, rather than raising a warning with the default warnings 
enabled.

>> Portable code should not rely on anything in cdefs.h.
> 
> Right - can you explain why it is ending up in your ObjC code?

Because it’s in cdefs.h, which is included by *every single userspace C 
header*.  cdefs.h must work with all C-family languages.

David

_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to