From owner-svn-src-head@FreeBSD.ORG Sun Dec 8 03:02:46 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 03C20934; Sun, 8 Dec 2013 03:02:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E3C8D1CB8; Sun, 8 Dec 2013 03:02:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rB832j9g055783; Sun, 8 Dec 2013 03:02:45 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rB832iiM055772; Sun, 8 Dec 2013 03:02:44 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201312080302.rB832iiM055772@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Sun, 8 Dec 2013 03:02:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259092 - in head/contrib/gcc: . cp doc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Dec 2013 03:02:46 -0000 Author: pfg Date: Sun Dec 8 03:02:44 2013 New Revision: 259092 URL: http://svnweb.freebsd.org/changeset/base/259092 Log: gcc: new fvisibility-ms-compat option Obtained from: gcc 4.3 (rev. 126088; GPLv2) MFC after: 3 weeks Modified: head/contrib/gcc/ChangeLog.gcc43 head/contrib/gcc/c.opt head/contrib/gcc/cp/ChangeLog.gcc43 head/contrib/gcc/cp/decl.c head/contrib/gcc/cp/decl2.c head/contrib/gcc/doc/invoke.texi Modified: head/contrib/gcc/ChangeLog.gcc43 ============================================================================== --- head/contrib/gcc/ChangeLog.gcc43 Sun Dec 8 02:48:10 2013 (r259091) +++ head/contrib/gcc/ChangeLog.gcc43 Sun Dec 8 03:02:44 2013 (r259092) @@ -45,6 +45,12 @@ * flags.h (force_align_functions_log): Delete. * toplev.c (force_align_functions_log): Delete. +2007-06-28 Geoffrey Keating (r126088) + + * doc/invoke.texi (C++ Dialect Options): Document + fvisibility-ms-compat. + * c.opt (fvisibility-ms-compat): New. + 2007-06-05 Joerg Wunsch (r125346) PR preprocessor/23479 Modified: head/contrib/gcc/c.opt ============================================================================== --- head/contrib/gcc/c.opt Sun Dec 8 02:48:10 2013 (r259091) +++ head/contrib/gcc/c.opt Sun Dec 8 03:02:44 2013 (r259092) @@ -741,6 +741,10 @@ fvisibility-inlines-hidden C++ ObjC++ Marks all inlined methods as having hidden visibility +fvisibility-ms-compat +C++ ObjC++ Var(flag_visibility_ms_compat) +Changes visibility to match Microsoft Visual Studio by default + fvtable-gc C++ ObjC++ Discard unused virtual functions Modified: head/contrib/gcc/cp/ChangeLog.gcc43 ============================================================================== --- head/contrib/gcc/cp/ChangeLog.gcc43 Sun Dec 8 02:48:10 2013 (r259091) +++ head/contrib/gcc/cp/ChangeLog.gcc43 Sun Dec 8 03:02:44 2013 (r259092) @@ -7,6 +7,13 @@ * typeck.c (cxx_alignof_expr): When alignof is used on a plain FUNCTION_DECL, return its alignment. +2007-06-28 Geoffrey Keating (r126088) + + * decl2.c (determine_visibility): Implement + flag_visibility_ms_compat effect on type info. + * decl.c (cxx_init_decl_processing): Implement + global effect of flag_visibility_ms_compat. + 2007-06-28 Geoffrey Keating (r126080) * decl2.c (start_objects): Mark constructor-runnning function Modified: head/contrib/gcc/cp/decl.c ============================================================================== --- head/contrib/gcc/cp/decl.c Sun Dec 8 02:48:10 2013 (r259091) +++ head/contrib/gcc/cp/decl.c Sun Dec 8 03:02:44 2013 (r259092) @@ -3157,6 +3157,9 @@ cxx_init_decl_processing (void) } if (flag_inline_functions) flag_inline_trees = 2; + + if (flag_visibility_ms_compat) + default_visibility = VISIBILITY_HIDDEN; /* Initially, C. */ current_lang_name = lang_name_c; Modified: head/contrib/gcc/cp/decl2.c ============================================================================== --- head/contrib/gcc/cp/decl2.c Sun Dec 8 02:48:10 2013 (r259091) +++ head/contrib/gcc/cp/decl2.c Sun Dec 8 03:02:44 2013 (r259092) @@ -1726,6 +1726,19 @@ determine_visibility (tree decl) but have no TEMPLATE_INFO, so don't try to check it. */ use_template = 0; } + else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl) + && flag_visibility_ms_compat) + { + /* Under -fvisibility-ms-compat, types are visible by default, + even though their contents aren't. */ + tree underlying_type = TREE_TYPE (DECL_NAME (decl)); + int underlying_vis = type_visibility (underlying_type); + if (underlying_vis == VISIBILITY_ANON + || CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type)) + constrain_visibility (decl, underlying_vis); + else + DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; + } else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl)) { /* tinfo visibility is based on the type it's for. */ Modified: head/contrib/gcc/doc/invoke.texi ============================================================================== --- head/contrib/gcc/doc/invoke.texi Sun Dec 8 02:48:10 2013 (r259091) +++ head/contrib/gcc/doc/invoke.texi Sun Dec 8 03:02:44 2013 (r259092) @@ -186,6 +186,7 @@ in the following sections. -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol -fno-default-inline -fvisibility-inlines-hidden @gol +-fvisibility-ms-compat @gol -Wabi -Wctor-dtor-privacy @gol -Wnon-virtual-dtor -Wreorder @gol -Weffc++ -Wno-deprecated -Wstrict-null-sentinel @gol @@ -1626,6 +1627,40 @@ Explicitly instantiated inline methods a as their linkage might otherwise cross a shared library boundary. @xref{Template Instantiation}. +@item -fvisibility-ms-compat +@opindex fvisibility-ms-compat +This flag attempts to use visibility settings to make GCC's C++ +linkage model compatible with that of Microsoft Visual Studio. + +The flag makes these changes to GCC's linkage model: + +@enumerate +@item +It sets the default visibility to @code{hidden}, like +@option{-fvisibility=hidden}. + +@item +Types, but not their members, are not hidden by default. + +@item +The One Definition Rule is relaxed for types without explicit +visibility specifications which are defined in more than one different +shared object: those declarations are permitted if they would have +been permitted when this option was not used. +@end enumerate + +In new code it is better to use @option{-fvisibility=hidden} and +export those classes which are intended to be externally visible. +Unfortunately it is possible for code to rely, perhaps accidentally, +on the Visual Studio behaviour. + +Among the consequences of these changes are that static data members +of the same type with the same name but defined in different shared +objects will be different, so changing one will not change the other; +and that pointers to function members defined in different shared +objects may not compare equal. When this flag is given, it is a +violation of the ODR to define types with the same name differently. + @item -fno-weak @opindex fno-weak Do not use weak symbol support, even if it is provided by the linker.