Bug#688357: clang: ignores __attribute__ when __GNUC__ is undefined

brian m. carlson sandals at crustytoothpaste.net
Fri Sep 21 23:55:49 UTC 2012


Package: clang
Version: 3.1-8
Severity: normal

I have a project that uses some GCC-specific features that do not work
in clang (see 653256).  Therefore, my code will only compile correctly
if I use clang -U__GNUC__ (or alternately, #undef __GNUC__ in one of the
headers).  If I do this, however, clang ignores the visibility
attributes I use and moreover, it does this *silently*.

If I use --save-temps, the preprocessed output does not contain the
visibility attributes I placed on the functions, and because I use
-fvisibility=hidden, those functions are all hidden instead of being
visible.  This leads to link errors.

I see some possible solutions here:

1. clang stops defining __GNUC__, since it isn't, but still accepts GCC
extensions (my preferred solution).
2. clang continues to (wrongly) define __GNUC__, but still accepts GCC
extensions when -U__GNUC__.
3. clang refuses to accept GCC extensions without __GNUC__, but
complains loudly when it encounters them.

The current status is not acceptable.

You can find source in the clang-test branch of
git://github.com/bk2204/drew.git.  You should be able to do:

  make CC="clang -U__GNUC__" CXX="clang++ -U__GNUC__".

The symbols in lib/libdrew/mem.o will all be hidden.  These symbols will
not be hidden if you omit the -U__GNUC__.  I would have sent
preprocessed source, but since this looks like a bug in the
preprocessor, this will have to do.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.5-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages clang depends on:
ii  libc6                2.13-35
ii  libclang-common-dev  3.1-8
ii  libffi5              3.0.10-3
ii  libgcc1              1:4.7.1-9
ii  libllvm3.1           3.1-2
ii  libstdc++6           4.7.1-9
ii  libstdc++6-4.6-dev   4.6.3-10

Versions of packages clang recommends:
ii  llvm-3.1-dev  3.1-2
ii  python        2.7.3-2

clang suggests no packages.

-- no debconf information

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-llvm-team/attachments/20120921/d5395b1c/attachment.pgp>


More information about the Pkg-llvm-team mailing list