Skip to content

Commit

Permalink
Change the way _EXPORT macros look.
Browse files Browse the repository at this point in the history
With the current setup, if you have a header file my_class.h

class BASE_EXPORT MyClass {
 public:
  void MyInlineMethod() { /* do stuff, inline */ }
};

then every cc file that includes my_class.h will have a public symbol
for MyInlineMethod (because inline methods need to be emitted to
every translation unit, and the linker sorts them out). With the
components build, the linker can't decide to drop these inline methods,
so every .so that uses this header file will have the same public symbol.

With this proposed change, the symbol will only be visible in the target
the header file belongs to, and it will be hidden in all other components.
That's cleaner, and it also prevents accident hidden dependencies (say
target A depends on B, and B depends on C. A accidentally uses an inline
function from a class in C. With this change, that would result in a linker
error, and an explicit dependency from A on C would have to be added).

Also add a missing CHROMEOS_IMPLEMENTATION define which went
unnoticed until now.

BUG=90078
TEST=Things still build.
TBR=ben, tony, viettrungluu, thestig, agl, willchan

Review URL: https://chromiumcodereview.appspot.com/10386108

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137130 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed May 15, 2012
1 parent abd0215 commit b387864
Show file tree
Hide file tree
Showing 31 changed files with 124 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ash/ash_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#endif // defined(ASH_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(ASH_IMPLEMENTATION)
#define ASH_EXPORT __attribute__((visibility("default")))
#else
#define ASH_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions base/base_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(BASE_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(BASE_IMPLEMENTATION)
#define BASE_EXPORT __attribute__((visibility("default")))
#else
#define BASE_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions base/i18n/base_i18n_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(BASE_I18N_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(BASE_I18N_IMPLEMENTATION)
#define BASE_I18N_EXPORT __attribute__((visibility("default")))
#else
#define BASE_I18N_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
3 changes: 3 additions & 0 deletions chromeos/chromeos.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'power_state_control_proto',
'power_supply_properties_proto',
],
'defines': [
'CHROMEOS_IMPLEMENTATION',
],
'sources': [
'chromeos_export.h',
'chromeos_switches.cc',
Expand Down
4 changes: 4 additions & 0 deletions chromeos/chromeos_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(CHROMEOS_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(CHROMEOS_IMPLEMENTATION)
#define CHROMEOS_EXPORT __attribute__((visibility("default")))
#else
#define CHROMEOS_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions content/common/content_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(CONTENT_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(CONTENT_IMPLEMENTATION)
#define CONTENT_EXPORT __attribute__((visibility("default")))
#else
#define CONTENT_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions crypto/crypto_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(CRYPTO_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(CRYPTO_IMPLEMENTATION)
#define CRYPTO_EXPORT __attribute__((visibility("default")))
#else
#define CRYPTO_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions gpu/command_buffer/client/gles2_c_lib_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(GLES2_C_LIB_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(GLES2_C_LIB_IMPLEMENTATION)
#define GLES2_C_LIB_EXPORT __attribute__((visibility("default")))
#else
#define GLES2_C_LIB_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions gpu/command_buffer/client/gles2_impl_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(GLES2_IMPL_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(GLES2_IMPL_IMPLEMENTATION)
#define GLES2_IMPL_EXPORT __attribute__((visibility("default")))
#else
#define GLES2_IMPL_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions gpu/command_buffer/common/gles2_utils_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(GLES2_UTILS_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(GLES2_UTILS_IMPLEMENTATION)
#define GLES2_UTILS_EXPORT __attribute__((visibility("default")))
#else
#define GLES2_UTILS_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions gpu/gpu_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(GPU_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(GPU_IMPLEMENTATION)
#define GPU_EXPORT __attribute__((visibility("default")))
#else
#define GPU_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ipc/ipc_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#endif // defined(IPC_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(IPC_IMPLEMENTATION)
#define IPC_EXPORT __attribute__((visibility("default")))
#else
#define IPC_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions media/base/media_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#endif // defined(MEDIA_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(MEDIA_IMPLEMENTATION)
#define MEDIA_EXPORT __attribute__((visibility("default")))
#else
#define MEDIA_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
5 changes: 5 additions & 0 deletions net/base/net_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
#endif // defined(NET_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(NET_IMPLEMENTATION)
#define NET_EXPORT __attribute__((visibility("default")))
#define NET_EXPORT_PRIVATE __attribute__((visibility("default")))
#else
#define NET_EXPORT
#define NET_EXPORT_PRIVATE
#endif
#endif

#else /// defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ppapi/proxy/ppapi_proxy_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(PPAPI_PROXY_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(PPAPI_PROXY_IMPLEMENTATION)
#define PPAPI_PROXY_EXPORT __attribute__((visibility("default")))
#else
#define PPAPI_PROXY_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ppapi/shared_impl/ppapi_shared_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(PPAPI_SHARED_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(PPAPI_SHARED_IMPLEMENTATION)
#define PPAPI_SHARED_EXPORT __attribute__((visibility("default")))
#else
#define PPAPI_SHARED_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ppapi/thunk/ppapi_thunk_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(PPAPI_THUNK_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(PPAPI_THUNK_IMPLEMENTATION)
#define PPAPI_THUNK_EXPORT __attribute__((visibility("default")))
#else
#define PPAPI_THUNK_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions printing/printing_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(PRINTING_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(PRINTING_IMPLEMENTATION)
#define PRINTING_EXPORT __attribute__((visibility("default")))
#else
#define PRINTING_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions sql/sql_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(SQL_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(SQL_IMPLEMENTATION)
#define SQL_EXPORT __attribute__((visibility("default")))
#else
#define SQL_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ui/aura/aura_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#endif // defined(AURA_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(AURA_IMPLEMENTATION)
#define AURA_EXPORT __attribute__((visibility("default")))
#else
#define AURA_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ui/base/ui_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#endif // defined(UI_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(UI_IMPLEMENTATION)
#define UI_EXPORT __attribute__((visibility("default")))
#else
#define UI_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ui/compositor/compositor_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(COMPOSITOR_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(COMPOSITOR_IMPLEMENTATION)
#define COMPOSITOR_EXPORT __attribute__((visibility("default")))
#else
#define COMPOSITOR_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ui/gl/gl_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(GL_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(GL_IMPLEMENTATION)
#define GL_EXPORT __attribute__((visibility("default")))
#else
#define GL_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ui/oak/oak_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#endif // defined(OAK_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(OAK_IMPLEMENTATION)
#define OAK_EXPORT __attribute__((visibility("default")))
#else
#define OAK_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ui/surface/surface_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(SURFACE_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(SURFACE_IMPLEMENTATION)
#define SURFACE_EXPORT __attribute__((visibility("default")))
#else
#define SURFACE_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions ui/views/views_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#endif // defined(VIEWS_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(VIEWS_IMPLEMENTATION)
#define VIEWS_EXPORT __attribute__((visibility("default")))
#else
#define VIEWS_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions webkit/appcache/appcache_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(APPCACHE_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(APPCACHE_IMPLEMENTATION)
#define APPCACHE_EXPORT __attribute__((visibility("default")))
#else
#define APPCACHE_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions webkit/blob/blob_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(BLOB_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(BLOB_IMPLEMENTATION)
#define BLOB_EXPORT __attribute__((visibility("default")))
#else
#define BLOB_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions webkit/forms/webkit_forms_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(WEBKIT_FORMS_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(WEBKIT_FORMS_IMPLEMENTATION)
#define WEBKIT_FORMS_EXPORT __attribute__((visibility("default")))
#else
#define WEBKIT_FORMS_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions webkit/glue/webkit_glue_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(WEBKIT_GLUE_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(WEBKIT_GLUE_IMPLEMENTATION)
#define WEBKIT_GLUE_EXPORT __attribute__((visibility("default")))
#else
#define WEBKIT_GLUE_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down
4 changes: 4 additions & 0 deletions webkit/plugins/webkit_plugins_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#endif // defined(WEBKIT_PLUGINS_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(WEBKIT_PLUGINS_IMPLEMENTATION)
#define WEBKIT_PLUGINS_EXPORT __attribute__((visibility("default")))
#else
#define WEBKIT_PLUGINS_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
Expand Down

0 comments on commit b387864

Please sign in to comment.