diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-09-17 19:04:42 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-10-20 16:20:34 +0000 |
commit | 629ceec208ad5fe9f5d201fc42fce611e55c567d (patch) | |
tree | a37ec882c3c81ee20331a65b28d891febaac9bd1 /src/corelib | |
parent | 2538b53340a4ef1d96b9eb0e43311b1e5ff1c54a (diff) |
Update qversiontagging.cpp not to use too much assembler magic
The only reason I had used them in the first place was because C
preprocessor macros cannot call themselves recursively. But the magic
was too magic and caused issues with some builds, so let's choose the
safer option.
Anyway, this solution now works for all ELF architectures, independent
of the processor, whereas previously it was restricted to x86 and Linux/
FreeBSD. However, this does not apply to the assembly in
qversiontagging.h.
Change-Id: I42e7ef1a481840699a8dffff1404f032fc5cacb8
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/global.pri | 28 | ||||
-rw-r--r-- | src/corelib/global/qversiontagging.cpp | 79 |
2 files changed, 50 insertions, 57 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index eb8600f796..8ecde5a769 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -27,7 +27,8 @@ SOURCES += \ global/qmalloc.cpp \ global/qnumeric.cpp \ global/qlogging.cpp \ - global/qhooks.cpp + global/qhooks.cpp \ + global/qversiontagging.cpp # qlibraryinfo.cpp includes qconfig.cpp INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global @@ -58,28 +59,3 @@ journald { syslog { DEFINES += QT_USE_SYSLOG } - -linux|freebsd { - VERSIONTAGGING_SOURCES = global/qversiontagging.cpp - ltcg|clang { - versiontagging_compiler.commands = $$QMAKE_CXX -c $(CXXFLAGS) $(INCPATH) - - # Disable LTO, as the global inline assembly may not get processed - versiontagging_compiler.commands += -fno-lto - - # Disable the integrated assembler for Clang, since it can't parse with - # the alternate macro syntax in use in qversiontagging.cpp - clang: versiontagging_compiler.commands += -no-integrated-as - - versiontagging_compiler.commands += -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} - versiontagging_compiler.dependency_type = TYPE_C - versiontagging_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} - versiontagging_compiler.input = VERSIONTAGGING_SOURCES - versiontagging_compiler.variable_out = OBJECTS - versiontagging_compiler.name = compiling[versiontagging] ${QMAKE_FILE_IN} - silent: versiontagging_compiler.commands = @echo compiling[versiontagging] ${QMAKE_FILE_IN} && $$versiontagging_compiler.commands - QMAKE_EXTRA_COMPILERS += versiontagging_compiler - } else { - SOURCES += $$VERSIONTAGGING_SOURCES - } -} diff --git a/src/corelib/global/qversiontagging.cpp b/src/corelib/global/qversiontagging.cpp index 66d3f8d00f..fc81d9bb93 100644 --- a/src/corelib/global/qversiontagging.cpp +++ b/src/corelib/global/qversiontagging.cpp @@ -33,37 +33,54 @@ #include "qglobal.h" -#if defined(Q_CC_GNU) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)) && defined(Q_PROCESSOR_X86) && !defined(QT_STATIC) -# define SYM QT_MANGLE_NAMESPACE(qt_version_tag) -# define SSYM QT_STRINGIFY(SYM) +#define SYM QT_MANGLE_NAMESPACE(qt_version_tag) +//#define SSYM QT_STRINGIFY(SYM) -asm( -// ASM macro that makes one ELF versioned symbol -".macro make_versioned_symbol plainsym versionedsym\n" -".globl plainsym\n" -".type plainsym, @object\n" -".size plainsym, 1\n" -".symver plainsym, versionedsym\n" -"plainsym :\n" -".endm\n" - -// ASM macro that makes one ELF versioned symbol qt_version_tag{sep}Qt_{major}.{minor} -// that is an alias to qt_version_tag_{major}_{minor}. -// The {sep} parameter must be @ for all old versions and @@ for the current version. -".macro make_one_tag major minor sep\n" -" make_versioned_symbol " SSYM "_\\major\\()_\\minor, " SSYM "\\sep\\()Qt_\\major\\().\\minor\n" -".endm\n" - -".altmacro\n" -".bss\n" -".set qt_version_major, " QT_STRINGIFY(QT_VERSION) " >> 16\n" // set qt_version_major -".set qt_version_minor, 0\n" // set qt_version_minor to 0 (it will grow to the current) -".rept (" QT_STRINGIFY(QT_VERSION) " >> 8) & 0xff\n" // repeat minor version times (0 to N-1) -" make_one_tag %qt_version_major, %qt_version_minor, @\n" -" .set qt_version_minor, (qt_version_minor + 1)\n" -".endr\n" -" make_one_tag %qt_version_major, %qt_version_minor, @@\n" // call the macro for the current version -" .space 1\n" // variable is 1 byte, value 0 -); +#if defined(Q_CC_GNU) && defined(Q_OF_ELF) +# define make_versioned_symbol2(sym, m, n, separator) \ + Q_CORE_EXPORT extern const char sym ## _ ## m ## _ ## n = 0; \ + asm(".symver " QT_STRINGIFY(sym) "_" QT_STRINGIFY(m) "_" QT_STRINGIFY(n) ", " \ + QT_STRINGIFY(sym) separator "Qt_" QT_STRINGIFY(m) "." QT_STRINGIFY(n)) +#else +# define make_versioned_symbol2(sym, m, n, separator) +#endif +#define make_versioned_symbol(sym, m, n, separator) make_versioned_symbol2(sym, m, n, separator) +extern "C" { +#if QT_VERSION_MINOR > 0 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 0, "@"); +#endif +#if QT_VERSION_MINOR > 1 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 1, "@"); +#endif +#if QT_VERSION_MINOR > 2 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 2, "@"); +#endif +#if QT_VERSION_MINOR > 3 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 3, "@"); +#endif +#if QT_VERSION_MINOR > 4 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 4, "@"); #endif +#if QT_VERSION_MINOR > 5 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 5, "@"); +#endif +#if QT_VERSION_MINOR > 6 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 6, "@"); +#endif +#if QT_VERSION_MINOR > 7 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 7, "@"); +#endif +#if QT_VERSION_MINOR > 8 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 8, "@"); +#endif +#if QT_VERSION_MINOR > 9 +make_versioned_symbol(SYM, QT_VERSION_MAJOR, 9, "@"); +#endif +#if QT_VERSION_MINOR > 10 +# error "Please update this file with more Qt versions." +#endif + +// the default version: +make_versioned_symbol(SYM, QT_VERSION_MAJOR, QT_VERSION_MINOR, "@@"); +} |