Linker magic to make compiling against InterAspect easy.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Wed, 3 Feb 2010 23:08:38 +0000 (18:08 -0500)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Wed, 3 Feb 2010 23:08:38 +0000 (18:08 -0500)
src/Makefile.am
src/aop-main.c
src/aop.h

index 3d327f8b17759767aca4800b38f07852216c3247..57fb87493b8964494dcb9d2d7d18d71dca73e9d0 100644 (file)
@@ -1,4 +1,5 @@
 lib_LTLIBRARIES = libinteraspect.la
 libinteraspect_la_SOURCES = aop-main.c
-libinteraspect_la_LDFLAGS = -version-info 1:0:0
+libinteraspect_la_CFLAGS = -Wall -Werror -fvisibility=hidden -prefer-pic
+libinteraspect_la_LDFLAGS = -static -prefer-pic -version-info 1:0:0
 libinteraspect_la_CPPFLAGS = -DHAVE_CONFIG_H -DIN_GCC -I$(gcc_includes)
index 547dc3821b3eda9b1019a0fdd167614943b54969..c7d3bd73a1c500bd9d68005aa2b75852dc2bb1d6 100644 (file)
@@ -75,7 +75,8 @@ static struct opt_pass template_pass = {
   .todo_flags_finish = TODO_update_ssa,
 };
 
-void aop_register_pass (const char *pass_name, pass_callback callback)
+void
+aop_register_pass (const char *pass_name, pass_callback callback)
 {
   struct opt_pass *pass_aop;
   struct register_pass_info pass_info;
@@ -100,7 +101,8 @@ void aop_register_pass (const char *pass_name, pass_callback callback)
 
 /* Free memory taken up by struct opt_pass objects saved in the
    aop_pass_list vector as well as the vector itself. */
-static void cleanup_passes ()
+static void
+cleanup_passes ()
 {
   int i;
   struct opt_pass *pass;
@@ -116,16 +118,25 @@ static void cleanup_passes ()
 
 /* This is the last plug-in function called before GCC exits.  Clean
    up all the memory we allocated. */
-static void aop_cleanup (void *event_date, void *data)
+static void
+aop_cleanup (void *event_date, void *data)
 {
   cleanup_passes();
 }
 
 /* GCC calls this to initialize a plug-in.  Once InterAspect
    initializes, it calls down into its client plug-in's
-   initialization. */
-int plugin_init (struct plugin_name_args *plugin_info,
-                struct plugin_gcc_version *version)
+   initialization.
+
+   By design, this function should be the _only_ exported (externally
+   visible) function in the compbined InterAspect/client package.
+
+   Note that the compiler is set to automatically mark function
+   definitions with "hidden" visibility.  We override that behavior
+   here. */
+__attribute__((visibility("default"))) int
+plugin_init (struct plugin_name_args *plugin_info,
+            struct plugin_gcc_version *version)
 {
   fprintf (stderr, "InterAspect init.\n");
 
index 4e74025c900046aef65b065f07f828e4f53e8ed5..bc7857b77d9ae69c2fd5257efdfec8b914d8cbf9 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
    calls can pass values from the running program to the advice
    function. */
 
+/* Client plug-in _must_ include this line to indicate that it is
+   GPLv3 compatible.*/
+#define AOP_I_AM_GPL_COMPATIBLE()                                      \
+  __attribute__((visibility("default"))) int plugin_is_GPL_compatible;
+
+/* Define aop_main using the AOP_MAIN_PROTO macro.  Absolutely do not
+   just declare it as a void function! */
+#define AOP_MAIN_PROTO __attribute__((visibility("hidden"))) void
+
 typedef unsigned int (*pass_callback)();
 
 void aop_register_pass(const char *pass_name, pass_callback callback);