[flac-dev] Building FLAC with LTO

LRN lrn1986 at gmail.com
Sun May 4 11:32:58 PDT 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tried to do this, gcc complained a lot about undefined references.
After a bit of mucking with the code, i came up with a few patches. This
might be a good conversation starter.

The build that i've got out of this does pass the testsuite.

To enable LTO you just need to apply these (for non-W32 builds you probably
only need one of the patches) and configure with CFLAGS="... -flto"
LDFLAGS="... -flto".

- -- 
O< ascii ribbon - stop html email! - www.asciiribbon.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)

iQEcBAEBAgAGBQJTZofZAAoJEOs4Jb6SI2CwVs4IAOKqObfHqiEIY5L2pi75l8Fh
siFVMIv4Z/pO06lQxM8kO3zQ8F4aTETtM3JRfmb1kRwlMw42KuEedUTB6iwnSS3q
XnvmPV6I7BFb8ISaMei/yIKktrNNFA7jF2Oc0j08rgO2fI1ieXFcednBPkYFn9Wy
uwdngBHNQY8EKP1O2ahUfbQ5gFmZyMFlronigBbSpsz8Q0HjH0puG/nzsE1c9Iop
Db6il2GXNIkuXpp+Jbxj153zvFYBqjvk48fKMvMtQeWSaOh7/2AphFvG5VmeXE0+
ZzPJOInTdowjJem9c8dT1feJpdYU5tHKXGu1DCuj7xNWncq/1FjcV3N3vrMjvwg=
=a05t
-----END PGP SIGNATURE-----
-------------- next part --------------
--- flac-1.3.0/src/libFLAC/include/private/ogg_mapping.h.orig	2013-05-26 09:30:33.932201700 +0000
+++ flac-1.3.0/src/libFLAC/include/private/ogg_mapping.h	2014-05-03 09:05:25.669393200 +0000
@@ -38,27 +38,28 @@
 /** The length of the packet type field in bytes. */
 #define FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH (1u)
 
-extern const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */
-
-extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */
-
 /** The length of the 'FLAC' magic in bytes. */
 #define FLAC__OGG_MAPPING_MAGIC_LENGTH (4u)
 
-extern const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC; /* = "FLAC" */
-
-extern const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */
-extern const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */
-
 /** The length of the Ogg FLAC mapping major version number in bytes. */
 #define FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH (1u)
 
 /** The length of the Ogg FLAC mapping minor version number in bytes. */
 #define FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH (1u)
 
-extern const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */
-
 /** The length of the #-of-header-packets number bytes. */
 #define FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH (2u)
 
+
+#define FLAC__OGG_MAPPING_PACKET_TYPE_LEN ((unsigned) 8) /* bits */
+
+#define FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE ((FLAC__byte) 0x7f)
+
+#define FLAC__OGG_MAPPING_MAGIC ((const FLAC__byte * const)"FLAC")
+
+#define FLAC__OGG_MAPPING_VERSION_MAJOR_LEN ((unsigned) 8) /* bits */
+#define FLAC__OGG_MAPPING_VERSION_MINOR_LEN ((unsigned) 8) /* bits */
+
+#define FLAC__OGG_MAPPING_NUM_HEADERS_LEN ((unsigned) 16) /* bits */
+
 #endif
--- flac-1.3.0/src/libFLAC/ogg_mapping.c.orig	2013-05-26 09:30:33.932201700 +0000
+++ flac-1.3.0/src/libFLAC/ogg_mapping.c	2014-05-03 08:55:02.631277400 +0000
@@ -36,13 +36,3 @@
 
 #include "private/ogg_mapping.h"
 
-const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */
-
-const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE = 0x7f;
-
-const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC = (const FLAC__byte * const)"FLAC";
-
-const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */
-const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */
-
-const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */
-------------- next part --------------
--- flac-1.3.0/include/FLAC/export.h.orig	2013-05-26 09:30:33.924201900 +0000
+++ flac-1.3.0/include/FLAC/export.h	2014-05-03 09:11:50.799298400 +0000
@@ -59,11 +59,19 @@
 #if defined(FLAC__NO_DLL)
 #define FLAC_API
 
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) || defined(__MINGW32__)
 #ifdef FLAC_API_EXPORTS
-#define	FLAC_API	_declspec(dllexport)
+#if defined(__GNUC__)
+#define	FLAC_API	__attribute__((dllexport))
+#else
+#define	FLAC_API	__declspec(dllexport)
+#endif
 #else
-#define FLAC_API	_declspec(dllimport)
+#if defined(__GNUC__)
+#define	FLAC_API
+#else
+#define	FLAC_API	__declspec(dllimport)
+#endif
 #endif
 
 #elif defined(FLAC__USE_VISIBILITY_ATTR)
--- flac-1.3.0/include/FLAC++/export.h.orig	2013-05-26 09:30:33.920202000 +0000
+++ flac-1.3.0/include/FLAC++/export.h	2014-05-03 09:12:38.663876500 +0000
@@ -59,11 +59,19 @@
 #if defined(FLAC__NO_DLL)
 #define FLACPP_API
 
-#elif defined(_MSC_VER)
-#ifdef FLACPP_API_EXPORTS
-#define	FLACPP_API	_declspec(dllexport)
-#else
-#define FLACPP_API	_declspec(dllimport)
+#elif defined(_MSC_VER) || defined(__MINGW32__)
+#ifdef FLACPP_API_EXPORTS
+#if defined(__GNUC__)
+#define	FLACPP_API	__attribute__((dllexport))
+#else
+#define	FLACPP_API	__declspec(dllexport)
+#endif
+#else
+#if defined(__GNUC__)
+#define	FLACPP_API
+#else
+#define	FLACPP_API	__declspec(dllimport)
+#endif
 #endif
 
 #elif defined(FLAC__USE_VISIBILITY_ATTR)
--- flac-1.3.0/configure.ac.orig	2013-05-27 08:08:57.218577500 +0000
+++ flac-1.3.0/configure.ac	2014-05-03 09:13:42.351463800 +0000
@@ -386,6 +386,9 @@
 		CFLAGS="$CFLAGS -fvisibility=hidden"
 		CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
 		fi
+	if test "$OBJ_FORMAT" = win32; then
+		CPPFLAGS="$CPPFLAGS -DFLAC_API_EXPORTS=1 -DFLACPP_API_EXPORTS=1"
+		fi
 
 	if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then
 		XIPH_ADD_CFLAGS([-fgnu89-inline])
-------------- next part --------------
--- flac-1.3.0/src/flac/Makefile.am.orig	2013-05-26 09:30:33.924201900 +0000
+++ flac-1.3.0/src/flac/Makefile.am	2014-05-03 09:44:59.262301200 +0000
@@ -44,6 +44,10 @@
 	utils.h \
 	vorbiscomment.h
 
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
 flac_LDADD = \
 	$(top_builddir)/src/share/utf8/libutf8.la \
 	$(top_builddir)/src/share/grabbag/libgrabbag.la \
@@ -51,6 +55,7 @@
 	$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
 	$(top_builddir)/src/share/replaygain_synthesis/libreplaygain_synthesis.la \
 	$(top_builddir)/src/libFLAC/libFLAC.la \
+	$(win_utf8_lib) \
 	@LIBICONV@ \
 	-lm
 
--- flac-1.3.0/src/metaflac/Makefile.am.orig	2013-05-26 09:30:33.936201600 +0000
+++ flac-1.3.0/src/metaflac/Makefile.am	2014-05-03 09:46:35.618536900 +0000
@@ -42,12 +42,17 @@
 	utils.h
 metaflac_LDFLAGS = $(AM_LDFLAGS)
 
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
 metaflac_LDADD = \
 	$(top_builddir)/src/share/grabbag/libgrabbag.la \
 	$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
 	$(top_builddir)/src/share/getopt/libgetopt.la \
 	$(top_builddir)/src/share/utf8/libutf8.la \
 	$(top_builddir)/src/libFLAC/libFLAC.la \
+	$(win_utf8_lib) \
 	@LIBICONV@
 
 CLEANFILES = metaflac.exe
--- flac-1.3.0/src/test_grabbag/cuesheet/Makefile.am.orig	2013-05-26 09:30:33.940201500 +0000
+++ flac-1.3.0/src/test_grabbag/cuesheet/Makefile.am	2014-05-03 09:48:29.464493500 +0000
@@ -24,9 +24,15 @@
 noinst_PROGRAMS = test_cuesheet
 test_cuesheet_SOURCES = \
 	main.c
+
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
 test_cuesheet_LDADD = \
 	$(top_builddir)/src/share/grabbag/libgrabbag.la \
 	$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
-	$(top_builddir)/src/libFLAC/libFLAC.la
+	$(top_builddir)/src/libFLAC/libFLAC.la \
+	$(win_utf8_lib)
 
 CLEANFILES = test_cuesheet.exe
--- flac-1.3.0/src/test_grabbag/picture/Makefile.am.orig	2013-05-26 09:30:33.940201500 +0000
+++ flac-1.3.0/src/test_grabbag/picture/Makefile.am	2014-05-03 09:49:12.014396600 +0000
@@ -25,8 +25,13 @@
 test_picture_SOURCES = \
 	main.c
 
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
 test_picture_LDADD = \
 	$(top_builddir)/src/share/grabbag/libgrabbag.la \
-	$(top_builddir)/src/libFLAC/libFLAC.la
+	$(top_builddir)/src/libFLAC/libFLAC.la \
+	$(win_utf8_lib)
 
 CLEANFILES = test_picture.exe
--- flac-1.3.0/src/test_seeking/Makefile.am.orig	2013-05-26 09:30:33.944201400 +0000
+++ flac-1.3.0/src/test_seeking/Makefile.am	2014-05-03 09:50:20.531097100 +0000
@@ -25,8 +25,14 @@
 AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
 
 noinst_PROGRAMS = test_seeking
+
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
 test_seeking_LDADD = \
-	$(top_builddir)/src/libFLAC/libFLAC.la
+	$(top_builddir)/src/libFLAC/libFLAC.la \
+	$(win_utf8_lib)
 
 test_seeking_SOURCES = \
 	main.c
--- flac-1.3.0/src/test_libFLAC++/Makefile.am.orig	2013-05-26 09:30:33.940201500 +0000
+++ flac-1.3.0/src/test_libFLAC++/Makefile.am	2014-05-03 09:51:08.574197800 +0000
@@ -22,12 +22,18 @@
 
 AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
 noinst_PROGRAMS = test_libFLAC++
+
+if OS_IS_WINDOWS
+win_utf8_lib = $(top_builddir)/src/share/win_utf8_io/libwin_utf8_io.la
+endif
+
 test_libFLAC___LDADD = \
 	$(top_builddir)/src/share/grabbag/libgrabbag.la \
 	$(top_builddir)/src/share/replaygain_analysis/libreplaygain_analysis.la \
 	$(top_builddir)/src/test_libs_common/libtest_libs_common.la \
 	$(top_builddir)/src/libFLAC++/libFLAC++.la \
 	$(top_builddir)/src/libFLAC/libFLAC.la \
+	$(win_utf8_lib) \
 	@OGG_LIBS@ \
 	-lm
 


More information about the flac-dev mailing list