mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-05 23:44:47 +01:00
Revert "build-sys: drop -mms-bitfields GCC flag"
This reverts commit 252bbcd2078aadc67a49bacd5b2cd4fd348a8dd7. After further discussion in !3511, we’ve decided that there are risks associated with this change, and it’s not the best way of addressing the original problem. The original motivation for the change turned out to be that `-mms-bitfields` was not handled by `windres`, which was receiving it from `pkg-config --cflags glib-2.0` in some projects. However, if `windres` is claiming to accept CFLAGS then it should accept (and ignore) `-mms-bitfields`, since the `-m` family of options are defined in `man gcc`, just like `-I`, `-D`, etc. There is some question that there might still be third party projects which are built with an old enough compiler that `-mms-bitfields` is not the compiler default. For that reason, we should either still continue to specify `-mms-bitfields` in the `.pc` file, or add a test to assert that third party projects are always compiled with `-mms-bitfields` set. But adding a new test for all third-party compilations is risky (if we get it wrong, things will break; and it’s a test which may behave differently on different platforms), so it seems safer to just keep `-mms-bitfields` in `.pc` for now. Once all compilers which we require specify `-mms-bitfields` by default, we can finally drop this flag (without adding a test for third-party compilations). See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3511
This commit is contained in:
parent
6e77bb3315
commit
627dc1415c
@ -65,10 +65,10 @@ Building software that just *uses* GLib or GTK also require to have
|
||||
the right compiler set up the right way. If you intend to use MinGW-GCC,
|
||||
follow the relevant instructions below in that case, too.
|
||||
|
||||
You should link to GLib using the `-mms-bitfields` GCC flag. It is the default
|
||||
since 2012 (GCC 4.7). This flag means that the struct layout rules are identical
|
||||
to those used by MSVC. This is essential if the same DLLs are to be usable both
|
||||
from gcc- and MSVC-compiled code.
|
||||
You should link to GLib using the `-mms-bitfields` GCC flag. This flag means
|
||||
that the struct layout rules are identical to those used by MSVC. This is
|
||||
essential if the same DLLs are to be usable both from gcc- and MSVC-compiled
|
||||
code.
|
||||
|
||||
## Cross-CRT issues
|
||||
|
||||
|
@ -443,7 +443,7 @@ pkg.generate(libglib,
|
||||
libraries : [libintl_deps],
|
||||
libraries_private : [win32_ldflags],
|
||||
subdirs : ['glib-2.0'],
|
||||
extra_cflags : ['-I${libdir}/glib-2.0/include'],
|
||||
extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
|
||||
variables : [
|
||||
'bindir=' + '${prefix}' / get_option('bindir'),
|
||||
'datadir=' + '${prefix}' / get_option('datadir'),
|
||||
|
@ -50,6 +50,7 @@ if cc.get_id() == 'msvc'
|
||||
noseh_link_args = ['/SAFESEH:NO']
|
||||
else
|
||||
noseh_link_args = []
|
||||
# -mms-bitfields vs -fnative-struct ?
|
||||
endif
|
||||
|
||||
host_system = host_machine.system()
|
||||
@ -2351,8 +2352,15 @@ else
|
||||
export_dynamic_ldflags = ['-Wl,--export-dynamic']
|
||||
endif
|
||||
|
||||
win32_cflags = []
|
||||
win32_ldflags = []
|
||||
if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
|
||||
# Ensure MSVC-compatible struct packing convention is used when
|
||||
# compiling for Win32 with gcc. It is used for the whole project and exposed
|
||||
# in glib-2.0.pc.
|
||||
win32_cflags = ['-mms-bitfields']
|
||||
add_project_arguments(win32_cflags, language : 'c')
|
||||
|
||||
# Win32 API libs, used only by libglib and exposed in glib-2.0.pc
|
||||
win32_ldflags = ['-lws2_32', '-lole32', '-lwinmm', '-lshlwapi', '-luuid']
|
||||
elif host_system == 'cygwin'
|
||||
|
Loading…
x
Reference in New Issue
Block a user