91f658c61f
At least when doing an aarch64 Flatpak build against org.freedesktop.Sdk//19.08, which uses GCC 9.2.0 and passes in `CXXFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection`, callVirtualMethod (in bridges/source/cpp_uno/gcc3_linux_aarch64/callvirtualfunction.cxx) would decrement the stack pointer another 16 bytes after the stackargs = alloca(...); and before the asm block, so in the called virtual function, arguments read from the stack would read garbage (and CustomTarget_testtools/uno_test would fail with SIGSEGV at > #0 0x0000ffffb733eb48 in rtl::OUString::operator= (this=0xaaaaf9c1ac30, str=...) at /run/build/libreoffice/include/rtl/ustring.hxx:453 > #1 0x0000ffffb733a7bc in bridge_object::assign (rData=..., bBool=true, cChar=64 u'@', nByte=17 '\021', nShort=4660, nUShort=65244, nLong=305419896, nULong=4275878552, nHyper=0, nUHyper=187651311381888, fFloat=17.0814991, fDouble=3.1415926358999999, eEnum=-1698898192, rStr=..., xTest=..., rAny=...) at /run/build/libreoffice/testtools/source/bridgetest/cppobj.cxx:99 > #2 0x0000ffffb733a87c in bridge_object::assign (rData=..., bBool=true, cChar=64 u'@', nByte=17 '\021', nShort=4660, nUShort=65244, nLong=305419896, nULong=4275878552, nHyper=0, nUHyper=187651311381888, fFloat=17.0814991, fDouble=3.1415926358999999, eEnum=-1698898192, rStr=..., xTest=..., rAny=..., rSequence=...) at /run/build/libreoffice/testtools/source/bridgetest/cppobj.cxx:115 > #3 0x0000ffffb733ade4 in bridge_object::Test_Impl::setValues (this=0xaaaaf9c1abb0, bBool=1 '\001', cChar=64 u'@', nByte=17 '\021', nShort=4660, nUShort=65244, nLong=305419896, nULong=4275878552, nHyper=0, nUHyper=187651311381888, fFloat=17.0814991, fDouble=3.1415926358999999, eEnum=-1698898192, rStr=..., xTest=..., rAny=..., rSequence=..., rStruct=...) at /run/build/libreoffice/testtools/source/bridgetest/cppobj.cxx:548 > #4 0x0000ffffb740bff4 in callVirtualFunction (function=281473755360772, gpr=0xffffd1ab1f28, fpr=0xffffd1ab1f68, stack=0xffffd1ab1d40, sp=8, ret=0xffffd1ab22c0) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/callvirtualfunction.cxx:63 > #5 0x0000ffffb740ca70 in (anonymous namespace)::call (proxy=0xaaaaf9c291c0, slot=..., returnType=0xaaaaf9c00770, count=17, parameters=0xaaaaf9c3a210, returnValue=0xffffd1ab22c0, arguments=0xffffd1ab2230, exception=0xffffd1ab2370) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx:178 > #6 0x0000ffffb740d4c4 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch (pUnoI=0xaaaaf9c291c0, pMemberDescr=0xaaaaf9c55950, pReturn=0xffffd1ab22c0, pArgs=0xffffd1ab2230, ppException=0xffffd1ab2370) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx:361 > #7 0x0000ffffb740720c in (anonymous namespace)::call (proxy=0xaaaaf9c549c0, description=..., returnType=0xaaaaf9c00770, count=17, parameters=0xaaaaf9c3a210, gpr=0xffffd1ab2510, fpr=0xffffd1ab2550, stack=0xffffd1ab2590, indirectRet=0xffffb7d24790) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:120 > #8 0x0000ffffb74079a0 in (anonymous namespace)::vtableCall (functionIndex=40, vtableOffset=0, gpr=0xffffd1ab2510, fpr=0xffffd1ab2550, stack=0xffffd1ab2590, indirectRet=0xffffb7d24790) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:291 > #9 0x0000ffffb7407b00 in (anonymous namespace)::vtableSlotCall (gpr0=187651311618536, gpr1=1, gpr2=64, gpr3=17, gpr4=4660, gpr5=65244, gpr6=305419896, gpr7=4275878552, fpr0=5.4321266044931319e-315, fpr1=3.1415926358999999, fpr2=0, fpr3=4.0039072046065485, fpr4=0, fpr5=4.003911019303815, fpr6=8.9589789687541617e+102, fpr7=-4.4588500238274385e-308) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:348 > #10 0x0000ffffb739e60c in bridge_test::performTest (xContext=..., xLBT=..., noCurrentContext=false) at /run/build/libreoffice/testtools/source/bridgetest/bridgetest.cxx:378 > #11 0x0000ffffb73a3d58 in bridge_test::TestBridgeImpl::run (this=0xaaaaf9c18550, rArgs=...) at /run/build/libreoffice/testtools/source/bridgetest/bridgetest.cxx:1162 > #12 0x0000aaaad292a3ec in sal_main () at /run/build/libreoffice/cpputools/source/unoexe/unoexe.cxx:509 > #13 0x0000aaaad29297a0 in main (argc=8, argv=0xffffd1ab31b8) at /run/build/libreoffice/cpputools/source/unoexe/unoexe.cxx:349 .) By experiment, I found the problematic thing to be -fstack-clash-protection, which can apparently be cancelled with a subsequent -fno-stack-clash-protection at least on that GCC 9.2.0. (And -f[no-]stack-clash-protection appears to only be available since GCC 8, and not at all for Clang, so check for it with HAVE_GCC_STACK_CLASH_PROTECTION.) Change-Id: If667fdf704b1ba20a04593b38d2d1f079280df41 Reviewed-on: https://gerrit.libreoffice.org/80701 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
273 lines
8.6 KiB
Makefile
273 lines
8.6 KiB
Makefile
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
|
#
|
|
# This file is part of the LibreOffice project.
|
|
#
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
#
|
|
|
|
$(eval $(call gb_Library_Library,$(gb_CPPU_ENV)_uno))
|
|
|
|
ifeq ($(CPUNAME),ARM)
|
|
|
|
ifneq ($(filter ANDROID DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_arm
|
|
bridge_noopt_objects := cpp2uno except uno2cpp
|
|
# HACK
|
|
$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,gcc3_uno)) : \
|
|
$(call gb_CustomTarget_get_workdir,bridges/source/cpp_uno/gcc3_linux_arm)/armhelper.objectlist
|
|
$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,gcc3_uno)) : \
|
|
EXTRAOBJECTLISTS += $(call gb_CustomTarget_get_workdir,bridges/source/cpp_uno/gcc3_linux_arm)/armhelper.objectlist
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),ARM64)
|
|
bridges_SELECTED_BRIDGE := gcc3_ios
|
|
bridge_noopt_objects := cpp2uno except uno2cpp
|
|
bridge_asm_objects := ios64_helper
|
|
|
|
else ifeq ($(CPUNAME),AARCH64)
|
|
|
|
ifneq ($(filter ANDROID DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_aarch64
|
|
bridge_exception_objects := abi uno2cpp
|
|
|
|
$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno, \
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/callvirtualfunction, \
|
|
$(if $(HAVE_GCC_STACK_CLASH_PROTECTION),-fno-stack-clash-protection) \
|
|
))
|
|
|
|
$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno, \
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/cpp2uno, \
|
|
-fstack-protector \
|
|
))
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),AXP)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_alpha
|
|
bridge_exception_objects := cpp2uno except uno2cpp
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),HPPA)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_hppa
|
|
bridge_noopt_objects := call cpp2uno except uno2cpp
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),IA64)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_ia64
|
|
bridge_asm_objects := call
|
|
bridge_exception_objects := except
|
|
bridge_noopt_objects := cpp2uno uno2cpp
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),INTEL)
|
|
|
|
ifneq ($(filter ANDROID DRAGONFLY FREEBSD LINUX NETBSD OPENBSD HAIKU,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_intel
|
|
bridge_asm_objects := call
|
|
bridge_exception_objects := cpp2uno except uno2cpp
|
|
bridge_noncallexception_objects := callvirtualmethod
|
|
else ifeq ($(OS),SOLARIS)
|
|
bridges_SELECTED_BRIDGE := gcc3_solaris_intel
|
|
bridge_exception_objects := cpp2uno except uno2cpp
|
|
bridge_noncallexception_objects := callvirtualmethod
|
|
else ifeq ($(COM),MSC)
|
|
bridges_SELECTED_BRIDGE := msvc_win32_intel
|
|
bridge_exception_objects := cpp2uno dllinit uno2cpp
|
|
bridge_noopt_objects := except
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),M68K)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_m68k
|
|
bridge_noopt_objects := cpp2uno except uno2cpp
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),GODSON)
|
|
|
|
ifneq ($(filter LINUX,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_mips
|
|
bridge_noopt_objects := cpp2uno uno2cpp
|
|
bridge_exception_objects := except
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),GODSON64)
|
|
|
|
ifneq ($(filter LINUX,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_mips64
|
|
bridge_asm_objects := call
|
|
bridge_noopt_objects := cpp2uno uno2cpp
|
|
bridge_exception_objects := except
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),POWERPC)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_powerpc
|
|
bridge_noopt_objects := uno2cpp
|
|
bridge_exception_objects := cpp2uno except
|
|
else ifeq ($(OS),AIX)
|
|
bridges_SELECTED_BRIDGE := gcc3_aix_powerpc
|
|
bridge_exception_objects := except
|
|
bridge_cxx_objects := cpp2uno uno2cpp
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),POWERPC64)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_powerpc64
|
|
bridge_noopt_objects := cpp2uno uno2cpp
|
|
bridge_exception_objects := except
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),S390)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_s390
|
|
bridge_exception_objects := cpp2uno except uno2cpp
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),S390X)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_s390x
|
|
bridge_exception_objects := cpp2uno except uno2cpp
|
|
endif
|
|
|
|
else ifeq ($(CPUNAME),SPARC)
|
|
|
|
ifneq ($(filter DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_sparc
|
|
bridge_asm_objects := call
|
|
bridge_noopt_objects := except
|
|
bridge_exception_objects := cpp2uno uno2cpp
|
|
else ifeq ($(OS),SOLARIS)
|
|
bridges_SELECTED_BRIDGE := gcc3_solaris_sparc
|
|
bridge_noopt_objects := cpp2uno uno2cpp
|
|
bridge_exception_objects := except
|
|
endif
|
|
|
|
else ifeq ($(OS)-$(CPUNAME),LINUX-SPARC64)
|
|
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_sparc64
|
|
bridge_asm_objects := call
|
|
bridge_noopt_objects := cpp2uno uno2cpp
|
|
bridge_exception_objects := except
|
|
|
|
else ifeq ($(CPUNAME),X86_64)
|
|
|
|
ifneq ($(filter ANDROID DRAGONFLY FREEBSD LINUX NETBSD OPENBSD HAIKU,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_linux_x86-64
|
|
bridge_asm_objects := call
|
|
bridge_noncallexception_noopt_objects := callvirtualmethod
|
|
bridge_exception_objects := abi cpp2uno except rtti uno2cpp
|
|
else ifneq ($(filter MACOSX iOS,$(OS)),)
|
|
bridges_SELECTED_BRIDGE := gcc3_macosx_x86-64
|
|
bridge_exception_objects := abi call cpp2uno except uno2cpp
|
|
bridge_noncallexception_noopt_objects := callvirtualmethod
|
|
else ifeq ($(COM),MSC)
|
|
bridges_SELECTED_BRIDGE := msvc_win32_x86-64
|
|
bridge_exception_objects := cpp2uno dllinit uno2cpp
|
|
bridge_noopt_objects := except
|
|
bridge_asm_objects := call
|
|
endif
|
|
|
|
endif
|
|
|
|
$(eval $(call gb_Library_use_internal_comprehensive_api,$(gb_CPPU_ENV)_uno,\
|
|
udkapi \
|
|
))
|
|
|
|
$(eval $(call gb_Library_set_include,$(gb_CPPU_ENV)_uno,\
|
|
-I$(SRCDIR)/bridges/inc \
|
|
$$(INCLUDE) \
|
|
))
|
|
|
|
ifeq ($(HAVE_POSIX_FALLOCATE),YES)
|
|
$(eval $(call gb_Library_add_defs,$(gb_CPPU_ENV)_uno,\
|
|
-DHAVE_POSIX_FALLOCATE \
|
|
))
|
|
endif
|
|
|
|
# In case someone enabled the non-standard -fomit-frame-pointer which does not
|
|
# work with the .cxx sources of this library.
|
|
# LTO causes crashes when enabled for this library
|
|
# In case the compiler supports AVX this code segfaults so specifically turn
|
|
# it off.
|
|
ifeq ($(COM),GCC)
|
|
$(eval $(call gb_Library_add_cxxflags,gcc3_uno,\
|
|
$(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-I$(ANDROID_BINUTILS_PREBUILT_ROOT)/lib/gcc/arm-linux-androideabi/4.9.x/include) \
|
|
-fno-omit-frame-pointer \
|
|
-fno-strict-aliasing \
|
|
$(if $(filter TRUE,$(ENABLE_LTO)),-fno-lto) \
|
|
$(if $(filter TRUE,$(HAVE_GCC_AVX)),-mno-avx) \
|
|
))
|
|
|
|
ifeq ($(filter ANDROID WNT DRAGONFLY FREEBSD NETBSD OPENBSD MACOSX iOS HAIKU,$(OS)),)
|
|
$(eval $(call gb_Library_add_libs,gcc3_uno,\
|
|
-ldl \
|
|
))
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(COM),GCC)
|
|
ifneq ($(COM_IS_CLANG),TRUE)
|
|
bridges_NON_CALL_EXCEPTIONS_FLAGS := -fnon-call-exceptions
|
|
endif
|
|
endif
|
|
|
|
$(eval $(call gb_Library_use_libraries,$(gb_CPPU_ENV)_uno,\
|
|
cppu \
|
|
sal \
|
|
))
|
|
|
|
$(foreach obj,$(bridge_exception_objects),\
|
|
$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/$(obj))) \
|
|
)
|
|
$(foreach obj,$(bridge_noncallexception_objects),\
|
|
$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/$(obj) \
|
|
, $(bridges_NON_CALL_EXCEPTIONS_FLAGS) )) \
|
|
)
|
|
$(foreach obj,$(bridge_noopt_objects),\
|
|
$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/$(obj) \
|
|
, $(gb_COMPILERNOOPTFLAGS))) \
|
|
)
|
|
$(foreach obj,$(bridge_noncallexception_noopt_objects),\
|
|
$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/$(obj) \
|
|
, $(gb_COMPILERNOOPTFLAGS) $(bridges_NON_CALL_EXCEPTIONS_FLAGS) )) \
|
|
)
|
|
$(foreach obj,$(bridge_cxx_objects),\
|
|
$(eval $(call gb_Library_add_cxxobjects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/$(obj))) \
|
|
)
|
|
$(foreach obj,$(bridge_asm_objects),\
|
|
$(eval $(call gb_Library_add_asmobjects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/$(obj))) \
|
|
)
|
|
|
|
$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/shared/bridge \
|
|
bridges/source/cpp_uno/shared/component \
|
|
bridges/source/cpp_uno/shared/types \
|
|
bridges/source/cpp_uno/shared/unointerfaceproxy \
|
|
bridges/source/cpp_uno/shared/vtablefactory \
|
|
bridges/source/cpp_uno/shared/vtables \
|
|
))
|
|
|
|
$(eval $(call gb_Library_add_cxxobjects,$(gb_CPPU_ENV)_uno,\
|
|
bridges/source/cpp_uno/shared/cppinterfaceproxy \
|
|
, $(gb_COMPILERNOOPTFLAGS) $(gb_LinkTarget_EXCEPTIONFLAGS) \
|
|
))
|
|
|
|
# vim: set noet sw=4 ts=4:
|