diff options
author | Svenn-Arne Dragly <s@dragly.com> | 2016-02-25 15:36:22 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2016-05-02 21:35:56 +0000 |
commit | f4f5219f0017d36e1b14fc4b88e9006b59c75b3f (patch) | |
tree | 2857566989115502c2be5846b6adfffb76825ee7 /src/corelib/plugin/qplugin.h | |
parent | 375adf412f44466a9ef588529ebbf7f102878919 (diff) |
Update support for Emscripten
Change-Id: I5d696f0dbc188acb4faad83240f7b1aa7177dc48
Reviewed-by: Svenn-Arne Dragly <s@dragly.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/corelib/plugin/qplugin.h')
-rw-r--r-- | src/corelib/plugin/qplugin.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 9b3725a718..9af1629a13 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -40,7 +40,6 @@ QT_BEGIN_NAMESPACE - #ifndef Q_EXTERN_C # ifdef __cplusplus # define Q_EXTERN_C extern "C" @@ -71,7 +70,20 @@ Q_DECLARE_TYPEINFO(QStaticPlugin, Q_PRIMITIVE_TYPE); void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); -#ifdef Q_OS_PNACL +#if defined(Q_OS_NACL_EMSCRIPTEN) +// It is important that the metadata is aligned in Emscripten because we are +// not allowed to read unaligned data in JS/Emscripten. +// Without this, importing static plugins will randomly fail because reading +// the offset 'size' value in QLibraryPrivate::fromRawMetaData is undefined behavior. +// For this purpose, aligning to 32 bits would suffice. +// Using 64 bits is probably overkill, but should ensure that this problem doesn't +// surface in other parts of the code. + +// TODO Do we need "section" and "used" attributes on Emscripten? +// TODO Should we reduce alignment to 32 bits? +# define QT_PLUGIN_METADATA_SECTION \ + __attribute__ ((section (".qtmetadata"))) __attribute__((used)) __attribute__((aligned(64))) +#elif defined(Q_OS_PNACL) // PNaCl does not support "section": // "Variable _ZL17qt_pluginMetaData has disallowed "section" attribute" // PNaCl is Q_CC_CLANG. TODO: should it not set Q_OF_ELF? |