Skip to contentSkip to conversation

Port: win32 DLLs don't support hidden symbols

PATCH New Michael Jeanson 2 participants 5 messages Feb 2, 2017 – Feb 21, 2017 1 message not in the archive Library code

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/5 Port: win32 DLLs don't support hidden symbols

---
 include/babeltrace/babeltrace-internal.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/babeltrace/babeltrace-internal.h +6 -0
index 0e73cdb..6f8e200 100644
@@ -161,8 +161,14 @@ extern int babeltrace_verbose, babeltrace_debug;
 
 /*
  * BT_HIDDEN: set the hidden attribute for internal functions
+ * On Windows, symbols are local unless explicitly exported,
+ * see https://gcc.gnu.org/wiki/Visibility
  */
+#if defined(_WIN32) || defined(__CYGWIN__)
+#define BT_HIDDEN
+#else
 #define BT_HIDDEN __attribute__((visibility("hidden")))
+#endif
 
 #define BT_CTF_MAJOR	1
 #define BT_CTF_MINOR	8
Signature · 6 lines
2.7.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#2 lore raw

PATCH 3/5 Port: Link with no-undefined on Windows

In reply to a message not in the archive
---
 configure.ac                       | 7 +++++++
 formats/bt-dummy/Makefile.am       | 1 +
 formats/ctf-metadata/Makefile.am   | 1 +
 formats/ctf-text/Makefile.am       | 1 +
 formats/ctf-text/types/Makefile.am | 2 ++
 formats/ctf/Makefile.am            | 1 +
 formats/ctf/ir/Makefile.am         | 2 ++
 formats/ctf/metadata/Makefile.am   | 2 ++
 formats/ctf/types/Makefile.am      | 2 ++
 formats/ctf/writer/Makefile.am     | 2 ++
 formats/lttng-live/Makefile.am     | 1 +
 lib/Makefile.am                    | 3 ++-
 lib/prio_heap/Makefile.am          | 2 ++
 tests/utils/tap/Makefile.am        | 1 +
 types/Makefile.am                  | 2 ++
 15 files changed, 29 insertions(+), 1 deletion(-)
configure.ac +7 -0
index 6d097bb..b674170 100644
@@ -128,6 +128,7 @@ AC_CHECK_FUNCS([ \
 
 MINGW32=no
 DEFAULT_ENABLE_DEBUG_INFO=yes
+LT_NO_UNDEFINED=""
 AS_CASE([$host_os],
   [solaris*|darwin*],
     [
@@ -136,10 +137,16 @@ AS_CASE([$host_os],
   [mingw*],
     [
 	MINGW32=yes
+	LT_NO_UNDEFINED="-no-undefined"
+    ],
+  [cygwin*],
+    [
+	LT_NO_UNDEFINED="-no-undefined"
     ]
 )
 
 AM_CONDITIONAL([BABELTRACE_BUILD_WITH_MINGW], [test "x$MINGW32" = "xyes"])
+AC_SUBST(LT_NO_UNDEFINED)
 
 # Check what libraries are required on this platform to link sockets programs.
 AX_LIB_SOCKET_NSL
formats/bt-dummy/Makefile.am +1 -0
index e8ae4de..7836b07 100644
@@ -7,6 +7,7 @@ libbabeltrace_dummy_la_SOURCES = \
 
 # Request that the linker keeps all static libraries objects.
 libbabeltrace_dummy_la_LDFLAGS = \
+	$(LT_NO_UNDEFINED) \
 	$(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION)
 
 libbabeltrace_dummy_la_LIBADD = \
formats/ctf-metadata/Makefile.am +1 -0
index 252d9af..20656b8 100644
@@ -7,6 +7,7 @@ libbabeltrace_ctf_metadata_la_SOURCES = \
 
 # Request that the linker keeps all static libraries objects.
 libbabeltrace_ctf_metadata_la_LDFLAGS = \
+	$(LT_NO_UNDEFINED) \
 	$(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION)
 
 libbabeltrace_ctf_metadata_la_LIBADD = \
formats/ctf-text/Makefile.am +1 -0
index f913de7..d773c81 100644
@@ -8,6 +8,7 @@ libbabeltrace_ctf_text_la_SOURCES = \
 	ctf-text.c
 
 libbabeltrace_ctf_text_la_LDFLAGS = \
+	$(LT_NO_UNDEFINED) \
 	$(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION) \
 	types/libctf-text-types.la
 
formats/ctf-text/types/Makefile.am +2 -0
index 71796f9..576d29d 100644
@@ -12,5 +12,7 @@ libctf_text_types_la_SOURCES = \
 	struct.c \
 	variant.c
 
+libctf_text_types_la_LDFLAGS = $(LT_NO_UNDEFINED)
+
 libctf_text_types_la_LIBADD = \
 	$(top_builddir)/lib/libbabeltrace.la
formats/ctf/Makefile.am +1 -0
index 2eb526d..23ae0b9 100644
@@ -13,6 +13,7 @@ libbabeltrace_ctf_la_SOURCES = \
 
 # Request that the linker keeps all static libraries objects.
 libbabeltrace_ctf_la_LDFLAGS = \
+	$(LT_NO_UNDEFINED) \
 	$(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION)
 
 libbabeltrace_ctf_la_LIBADD = \
formats/ctf/ir/Makefile.am +2 -0
index 1b7b5d8..6f5b06e 100644
@@ -20,6 +20,8 @@ libctf_ir_la_SOURCES = \
 	values.c \
 	ref.c
 
+libctf_ir_la_LDFLAGS = $(LT_NO_UNDEFINED)
+
 libctf_ir_la_LIBADD = \
 	$(top_builddir)/lib/libbabeltrace.la
 
formats/ctf/metadata/Makefile.am +2 -0
index cc67e9e..573f94d 100644
@@ -16,6 +16,7 @@ libctf_parser_la_SOURCES = ctf-lexer.l ctf-parser.y objstack.c
 # with bt_.
 libctf_parser_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir) \
 		-include $(srcdir)/ctf-scanner-symbols.h
+libctf_parser_la_LDFLAGS = $(LT_NO_UNDEFINED)
 
 libctf_ast_la_CFLAGS = $(AM_CFLAGS) -I$(builddir)
 libctf_ast_la_SOURCES = ctf-visitor-xml.c \
@@ -24,6 +25,7 @@ libctf_ast_la_SOURCES = ctf-visitor-xml.c \
 		ctf-visitor-generate-io-struct.c
 libctf_ast_la_LIBADD = \
 	$(top_builddir)/lib/libbabeltrace.la
+libctf_ast_la_LDFLAGS = $(LT_NO_UNDEFINED)
 
 if BABELTRACE_BUILD_WITH_LIBUUID
 libctf_ast_la_LIBADD += -luuid
formats/ctf/types/Makefile.am +2 -0
index 20c1fdd..a1bcfb2 100644
@@ -12,5 +12,7 @@ libctf_types_la_SOURCES = \
 	struct.c \
 	variant.c
 
+libctf_types_la_LDFLAGS = $(LT_NO_UNDEFINED)
+
 libctf_types_la_LIBADD = \
 	$(top_builddir)/lib/libbabeltrace.la
formats/ctf/writer/Makefile.am +2 -0
index 1f06c1a..e328084 100644
@@ -9,6 +9,8 @@ libctf_writer_la_SOURCES = \
 libctf_writer_la_LIBADD = \
 	$(top_builddir)/lib/libbabeltrace.la
 
+libctf_writer_la_LDFLAGS = $(LT_NO_UNDEFINED)
+
 if BABELTRACE_BUILD_WITH_LIBUUID
 libctf_writer_la_LIBADD += -luuid
 endif
formats/lttng-live/Makefile.am +1 -0
index d976979..e536160 100644
@@ -11,6 +11,7 @@ libbabeltrace_lttng_live_la_SOURCES = \
 
 # Request that the linker keeps all static libraries objects.
 libbabeltrace_lttng_live_la_LDFLAGS = \
+	$(LT_NO_UNDEFINED) \
 	$(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION)
 
 libbabeltrace_lttng_live_la_LIBADD = \
lib/Makefile.am +2 -1
index 007abb7..be029a7 100644
@@ -11,7 +11,8 @@ libbabeltrace_la_SOURCES = babeltrace.c \
 			   trace-collection.c \
 			   registry.c
 
-libbabeltrace_la_LDFLAGS = -version-info $(BABELTRACE_LIBRARY_VERSION)
+libbabeltrace_la_LDFLAGS = \
+	$(LT_NO_UNDEFINED) -version-info $(BABELTRACE_LIBRARY_VERSION)
 
 if ENABLE_DEBUG_INFO
 noinst_LTLIBRARIES = libdebug-info.la
lib/prio_heap/Makefile.am +2 -0
index fffa43d..82d7fad 100644
@@ -3,3 +3,5 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include
 noinst_LTLIBRARIES = libprio_heap.la
 
 libprio_heap_la_SOURCES = prio_heap.c
+
+libprio_heap_la_LDFLAGS = $(LT_NO_UNDEFINED)
tests/utils/tap/Makefile.am +1 -0
index 8b224c4..8a8ec12 100644
@@ -1,5 +1,6 @@
 noinst_LTLIBRARIES = libtap.la
 libtap_la_SOURCES = tap.c tap.h
+libtap_la_LDFLAGS = $(LT_NO_UNDEFINED)
 
 SCRIPT_LIST = tap.sh
 
types/Makefile.am +2 -0
index 0417519..bdaa84b 100644
@@ -12,3 +12,5 @@ libbabeltrace_types_la_SOURCES = \
 	struct.c \
 	variant.c \
 	types.c
+
+libbabeltrace_types_la_LDFLAGS = $(LT_NO_UNDEFINED)
Signature · 6 lines
2.7.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#3 lore raw

PATCH 4/5 Port: Link live lib with ctf to satisfy cygwin linker

In reply to a message not in the archive
---
 formats/lttng-live/Makefile.am | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
formats/lttng-live/Makefile.am +2 -1
index e536160..f5f291c 100644
@@ -15,4 +15,5 @@ libbabeltrace_lttng_live_la_LDFLAGS = \
 	$(LD_NO_AS_NEEDED) -version-info $(BABELTRACE_LIBRARY_VERSION)
 
 libbabeltrace_lttng_live_la_LIBADD = \
-	$(top_builddir)/lib/libbabeltrace.la
+	$(top_builddir)/lib/libbabeltrace.la \
+	$(top_builddir)/formats/ctf/libbabeltrace-ctf.la
Signature · 6 lines
2.7.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#4 lore raw

PATCH 5/5 Add empty plug-in hooks to prevent their elimination by the linker

In reply to a message not in the archive

From: Jérémie Galarneau <[email protected]>

---
 converter/babeltrace.c                 | 17 +++++++++++++++++
 formats/bt-dummy/bt-dummy.c            |  8 ++++++++
 formats/ctf-metadata/ctf-metadata.c    |  8 ++++++++
 formats/ctf-text/ctf-text.c            |  8 ++++++++
 formats/ctf/ctf.c                      |  8 ++++++++
 formats/lttng-live/lttng-live-plugin.c |  8 ++++++++
 6 files changed, 57 insertions(+)
converter/babeltrace.c +17 -0
index 2e4003c..f74384e 100644
@@ -76,6 +76,12 @@ static int opt_stream_intersection;
 
 static struct bt_format *fmt_read;
 
+void bt_dummy_hook(void);
+void bt_lttng_live_hook(void);
+void bt_ctf_hook(void);
+void bt_ctf_text_hook(void);
+void bt_ctf_metadata_hook(void);
+
 static
 void strlower(char *str)
 {
@@ -703,6 +709,15 @@ error_iter:
 	return ret;
 }
 
+void call_plugins_hooks(void)
+{
+	bt_dummy_hook();
+	bt_lttng_live_hook();
+	bt_ctf_hook();
+	bt_ctf_text_hook();
+	bt_ctf_metadata_hook();
+}
+
 int main(int argc, char **argv)
 {
 	int ret, partial_error = 0, open_success = 0;
@@ -711,6 +726,8 @@ int main(int argc, char **argv)
 	struct bt_context *ctx;
 	int i;
 
+	call_plugins_hooks();
+
 	opt_input_paths = g_ptr_array_new();
 
 	ret = parse_options(argc, argv);
formats/bt-dummy/bt-dummy.c +8 -0
index 6192e88..65f2308 100644
@@ -38,6 +38,14 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+void bt_dummy_hook(void)
+{
+	/*
+	 * Dummy function to prevent the linker from discarding this format as
+	 * "unused" in static builds.
+	 */
+}
+
 static
 int bt_dummy_write_event(struct bt_stream_pos *ppos, struct ctf_stream_definition *stream)
 {
formats/ctf-metadata/ctf-metadata.c +8 -0
index a5a74c3..a47fd36 100644
@@ -54,6 +54,14 @@ struct bt_format ctf_metadata_format = {
 	.close_trace = ctf_metadata_close_trace,
 };
 
+void bt_ctf_metadata_hook(void)
+{
+	/*
+	 * Dummy function to prevent the linker from discarding this format as
+	 * "unused" in static builds.
+	 */
+}
+
 static
 int ctf_metadata_trace_pre_handler(struct bt_stream_pos *ppos,
 			struct bt_trace_descriptor *td)
formats/ctf-text/ctf-text.c +8 -0
index cc22336..017f311 100644
@@ -139,6 +139,14 @@ struct ctf_callsite_dups *ctf_trace_callsite_lookup(struct ctf_trace *trace,
 			(gpointer) (unsigned long) callsite_name);
 }
 
+void bt_ctf_text_hook(void)
+{
+	/*
+	 * Dummy function to prevent the linker from discarding this format as
+	 * "unused" in static builds.
+	 */
+}
+
 int print_field(struct bt_definition *definition)
 {
 	/* Print all fields in verbose mode */
formats/ctf/ctf.c +8 -0
index 324b9f8..d6d078f 100644
@@ -157,6 +157,14 @@ struct bt_format ctf_format = {
 	.convert_index_timestamp = ctf_convert_index_timestamp,
 };
 
+void bt_ctf_hook(void)
+{
+	/*
+	 * Dummy function to prevent the linker from discarding this format as
+	 * "unused" in static builds.
+	 */
+}
+
 static
 uint64_t ctf_timestamp_begin(struct bt_trace_descriptor *descriptor,
 		struct bt_trace_handle *handle, enum bt_clock_type type)
formats/lttng-live/lttng-live-plugin.c +8 -0
index a1fbb9e..dfabb98 100644
@@ -41,6 +41,14 @@
 
 static volatile int should_quit;
 
+void bt_lttng_live_hook(void)
+{
+	/*
+	 * Dummy function to prevent the linker from discarding this format as
+	 * "unused" in static builds.
+	 */
+}
+
 int lttng_live_should_quit(void)
 {
 	return should_quit;
Signature · 6 lines
2.7.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#5 lore raw

Re: [PATCH babeltrace stable-1.5 1/5] Port: replace strerror_r() with glib g_strerror()

In reply to a message not in the archive

All patches were merged in stable-1.5.

Thanks!
Jérémie

Quoted 87 lines · Michael Jeanson
---
 configure.ac                             |  1 -
 include/babeltrace/babeltrace-internal.h | 12 ++++++------
 include/babeltrace/compat/string.h       | 26 --------------------------
 3 files changed, 6 insertions(+), 33 deletions(-)
configure.ac +0 -1
index 56255d0..6d097bb 100644
@@ -97,7 +97,6 @@ AC_FUNC_MALLOC
 AC_FUNC_MKTIME
 AC_FUNC_MMAP
 AC_FUNC_REALLOC
-AC_FUNC_STRERROR_R
 AC_CHECK_FUNCS([ \
        atexit \
        dirfd \
include/babeltrace/babeltrace-internal.h +6 -6
index a903c68..0e73cdb 100644
@@ -83,16 +83,16 @@ extern int babeltrace_verbose, babeltrace_debug;
 
 #define _bt_printf_perror(fp, fmt, args...)                            \
        ({                                                              \
-               char buf[PERROR_BUFLEN] = "Error in strerror_r()";      \
-               compat_strerror_r(errno, buf, sizeof(buf));             \
-               _bt_printfe(fp, "error", buf, fmt, ## args);            \
+               const char *errstr;                                     \
+               errstr = g_strerror(errno);                             \
+               _bt_printfe(fp, "error", errstr, fmt, ## args);         \
        })
 
 #define _bt_printfl_perror(fp, lineno, fmt, args...)                   \
        ({                                                              \
-               char buf[PERROR_BUFLEN] = "Error in strerror_r()";      \
-               compat_strerror_r(errno, buf, sizeof(buf));             \
-               _bt_printfle(fp, "error", lineno, buf, fmt, ## args);   \
+               const char *errstr;                                     \
+               errstr = g_strerror(errno);                             \
+               _bt_printfle(fp, "error", lineno, errstr, fmt, ## args);\
        })
 
 /* printf without lineno information */
include/babeltrace/compat/string.h +0 -27
index 6092616..c3325a3 100644
@@ -26,32 +26,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-
-/* XSI-compliant strerror_r */
-static inline
-int compat_strerror_r(int errnum, char *buf, size_t buflen)
-{
-       return strerror_r(errnum, buf, buflen);
-}
-
-#else
-
-/* GNU-compliant strerror_r */
-static inline
-int compat_strerror_r(int errnum, char *buf, size_t buflen)
-{
-       char *retbuf;
-
-       retbuf = strerror_r(errnum, buf, buflen);
-       if (retbuf != buf)
-               strncpy(buf, retbuf, buflen);
-       buf[buflen - 1] = '\0';
-       return 0;
-}
-
-#endif
-
 #ifdef HAVE_STRNLEN
 static inline
 size_t bt_strnlen(const char *str, size_t max)
--

2.7.4

Signature · 7 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev