Skip to content

Commit

Permalink
Add initial support for building AOO with Clang on Linux.
Browse files Browse the repository at this point in the history
This allows Ubuntu 16.04 to compile AOO with Clang 1.8 on an x86.

Other architectures probably don't work, as Clang 1.8 is pretty
strict about the low-level C++ ABI hacks in main/bridges, but at
least they should fail early in main/bridges instead of the
previous behaviour, where main/bridges compiles nothing when
"$(COM)" != "GCC" and main/i18npool then fails with a mysterious
"error: cannot get uno environments" message.

Patch by: me



git-svn-id: https://svn.apache.org/repos/asf/openoffice/trunk@1782030 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Damjan Jovanovic committed Feb 7, 2017
1 parent 0c223f2 commit bcc22a4
Show file tree
Hide file tree
Showing 28 changed files with 162 additions and 52 deletions.
11 changes: 11 additions & 0 deletions ext_libraries/coinmp/coinmp-1.7.6-clang-1.8.patch
@@ -0,0 +1,11 @@
--- misc/build/CoinMP-1.7.6/Cbc/src/Cbc_C_Interface.cpp 2013-04-10 18:58:16.000000000 +0200
+++ misc/build/CoinMP-1.7.6/Cbc/src/Cbc_C_Interface.cpp 2017-02-06 20:39:00.267698261 +0200
@@ -376,7 +376,7 @@

char * result = model->information_;

- if (VERBOSE > 0) printf("%s return %p\n", prefix, result);
+ if (VERBOSE > 0) printf("%s return %p\n", prefix, static_cast<void*>(result));
return result;
}
/* Copy in integer information */
2 changes: 1 addition & 1 deletion ext_libraries/coinmp/makefile.mk
Expand Up @@ -45,7 +45,7 @@ all:
TARFILE_NAME=CoinMP-1.7.6
TARFILE_MD5=1cce53bf4b40ae29790d2c5c9f8b1129

PATCH_FILES=coinmp-1.7.6.patch coinmp-1.7.6-clang.patch
PATCH_FILES=coinmp-1.7.6.patch coinmp-1.7.6-clang.patch coinmp-1.7.6-clang-1.8.patch
.IF "$(OS)"=="OS2"
PATCH_FILES+=coinmp-1.6.0-os2.patch
.ENDIF
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_alpha/makefile.mk
Expand Up @@ -34,7 +34,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)" == "GCCLINUXL"
.IF "$(OS)$(CPU)" == "LINUXL"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_arm/makefile.mk
Expand Up @@ -35,7 +35,7 @@ NO_BSYMBOLIC=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)" == "GCCLINUXRgcc3"
.IF "$(OS)$(CPU)$(COMNAME)" == "LINUXRgcc3"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_hppa/makefile.mk
Expand Up @@ -35,7 +35,7 @@ NO_BSYMBOLIC=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)" == "GCCLINUXH"
.IF "$(OS)$(CPU)" == "LINUXH"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_ia64/makefile.mk
Expand Up @@ -34,7 +34,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)" == "GCCLINUXAgcc3"
.IF "$(OS)$(CPU)$(COMNAME)" == "LINUXAgcc3"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
48 changes: 48 additions & 0 deletions main/bridges/source/cpp_uno/gcc3_linux_intel/abi.cxx
@@ -0,0 +1,48 @@
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/



// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_bridges.hxx"

#include <typeinfo>
#include <cstddef>

#include <uno/any2.h>
#include <cppu/macros.hxx>

#include "share.hxx"

// At least Clang 3.8 can't compile our CPPU_CURRENT_NAMESPACE::__cxa_get_globals()
// decleration with <exception> or anything else that indirectly includes <cxxabi.h>
// included, as it sees it as a an overload of __cxxabi::__cxa_get_globals() with a
// different return type. Thus, it has to be placed in a file that doesn't include
// those, and wrapped in a function:
namespace CPPU_CURRENT_NAMESPACE
{
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();

__cxa_eh_globals *__INTERNAL__cxa_get_globals() throw()
{
return __cxa_get_globals();
}
}
8 changes: 7 additions & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_intel/cpp2uno.cxx
Expand Up @@ -24,6 +24,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_bridges.hxx"

#include <typeinfo>
#include <exception>
#include <cstddef>
#include <cxxabi.h>

#include <com/sun/star/uno/genfunc.hxx>
#include "com/sun/star/uno/RuntimeException.hpp"
#include <uno/data.h>
Expand Down Expand Up @@ -412,7 +417,8 @@ unsigned char * codeSnippet(
struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; };

bridges::cpp_uno::shared::VtableFactory::Slot *
bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) {
bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block)
{
return static_cast< Slot * >(block) + 2;
}

Expand Down
24 changes: 20 additions & 4 deletions main/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx
Expand Up @@ -19,15 +19,23 @@
*
*************************************************************/



// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_bridges.hxx"

#include <cstdio>
#include <cstring>
#include <cstddef>
#include <exception>
#include <typeinfo>

#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
#include <cxxabi.h>
#include <hash_map>

#include <sys/param.h>

#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
#include <osl/diagnose.h>
Expand Down Expand Up @@ -147,7 +155,7 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR
buf.append( 'E' );

OString symName( buf.makeStringAndClear() );
rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
rtti = static_cast<type_info *>(dlsym( m_hApp, symName.getStr() ));

if (rtti)
{
Expand All @@ -167,20 +175,28 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR
char const * rttiName = symName.getStr() +4;
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr,"generated rtti for %s\n", rttiName );
#ifndef __GLIBCXX__ /* #i124421# */
const OString aCUnoName = OUStringToOString( unoName, RTL_TEXTENCODING_UTF8);
OSL_TRACE( "TypeInfo for \"%s\" not found and cannot be generated.\n", aCUnoName.getStr());
#endif /* __GLIBCXX__ */
#endif
#ifdef __GLIBCXX__ /* #i124421# */
if (pTypeDescr->pBaseTypeDescription)
{
// ensure availability of base
type_info * base_rtti = getRTTI(
(typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
rtti = new __si_class_type_info(
strdup( rttiName ), (__class_type_info *)base_rtti );
strdup( rttiName ), static_cast<__class_type_info *>(base_rtti) );
}
else
{
// this class has no base class
rtti = new __class_type_info( strdup( rttiName ) );
}
#else /* __GLIBCXX__ */
rtti = NULL;
#endif /* __GLIBCXX__ */

pair< t_rtti_map::iterator, bool > insertion(
m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
Expand Down
5 changes: 3 additions & 2 deletions main/bridges/source/cpp_uno/gcc3_linux_intel/makefile.mk
Expand Up @@ -34,7 +34,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)" == "GCCLINUXIgcc3"
.IF "$(OS)$(CPU)$(COMNAME)" == "LINUXIgcc3"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand All @@ -50,7 +50,8 @@ SLOFILES= \
$(SLO)$/except.obj \
$(SLO)$/cpp2uno.obj \
$(SLO)$/uno2cpp.obj \
$(SLO)$/call.obj
$(SLO)$/call.obj \
$(SLO)$/abi.obj

SHL1TARGET= $(TARGET)

Expand Down
14 changes: 9 additions & 5 deletions main/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx
Expand Up @@ -23,17 +23,14 @@

#include "uno/mapping.h"

#include <typeinfo>
#include <exception>
#include <cstddef>

namespace CPPU_CURRENT_NAMESPACE
{

void dummy_can_throw_anything( char const * );

// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h

#ifdef __GLIBCXX__
struct _Unwind_Exception
{
unsigned exception_class __attribute__((__mode__(__DI__)));
Expand Down Expand Up @@ -62,25 +59,32 @@ struct __cxa_exception

_Unwind_Exception unwindHeader;
};
#endif /* __GLIBCXX__ */

extern "C" void *__cxa_allocate_exception(
std::size_t thrown_size ) throw();
extern "C" void __cxa_throw (
void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));

#ifdef __GLIBCXX__
struct __cxa_eh_globals
{
__cxa_exception *caughtExceptions;
unsigned int uncaughtExceptions;
};
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
__cxa_eh_globals *__INTERNAL__cxa_get_globals () throw();
#endif /* __GLIBCXX__ */

// -----

//==================================================================================================
void raiseException(
uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
//==================================================================================================
#ifndef __GLIBCXX__
using __cxxabiv1:: __cxa_exception;
#endif /* __GLIBCXX__ */

void fillUnoException(
__cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
}
8 changes: 6 additions & 2 deletions main/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx
Expand Up @@ -24,7 +24,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_bridges.hxx"

#include <malloc.h>
#include <typeinfo>
#include <exception>
#include <cstddef>
#include <cxxabi.h>
#include <stdlib.h>

#include <com/sun/star/uno/genfunc.hxx>
#include "com/sun/star/uno/RuntimeException.hpp"
Expand Down Expand Up @@ -305,7 +309,7 @@ static void cpp_call(
catch (...)
{
// fill uno exception
fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
CPPU_CURRENT_NAMESPACE::fillUnoException( CPPU_CURRENT_NAMESPACE::__INTERNAL__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );

// temporary params
for ( ; nTempIndizes--; )
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_m68k/makefile.mk
Expand Up @@ -35,7 +35,7 @@ NO_BSYMBOLIC=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)" == "GCCLINUX6gcc3"
.IF "$(OS)$(CPU)$(COMNAME)" == "LINUX6gcc3"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_mips/makefile.mk
Expand Up @@ -34,7 +34,7 @@ NO_BSYMBOLIC=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)" == "GCCLINUXM"
.IF "$(OS)$(CPU)" == "LINUXM"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_powerpc/makefile.mk
Expand Up @@ -33,7 +33,7 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk

# --- Files --------------------------------------------------------
.IF "$(COM)$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "GCCLINUXPgcc3POWERPC"
.IF "$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "LINUXPgcc3POWERPC"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
Expand Up @@ -34,7 +34,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "GCCLINUXPgcc3POWERPC64"
.IF "$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "LINUXPgcc3POWERPC64"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_s390/makefile.mk
Expand Up @@ -34,7 +34,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "GCCLINUX3gcc3S390"
.IF "$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "LINUX3gcc3S390"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_s390x/makefile.mk
Expand Up @@ -34,7 +34,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "GCCLINUX3gcc3S390X"
.IF "$(OS)$(CPU)$(COMNAME)$(CPUNAME)" == "LINUX3gcc3S390X"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_sparc/makefile.mk
Expand Up @@ -33,7 +33,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)" == "GCCLINUXS"
.IF "$(OS)$(CPU)" == "LINUXS"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
2 changes: 1 addition & 1 deletion main/bridges/source/cpp_uno/gcc3_linux_x86-64/makefile.mk
Expand Up @@ -34,7 +34,7 @@ ENABLE_EXCEPTIONS=TRUE

# --- Files --------------------------------------------------------

.IF "$(COM)$(OS)$(CPU)$(COMNAME)" == "GCCLINUXXgcc3"
.IF "$(OS)$(CPU)$(COMNAME)" == "LINUXXgcc3"

.IF "$(cppu_no_leak)" == ""
CFLAGS += -DLEAK_STATIC_DATA
Expand Down
12 changes: 9 additions & 3 deletions main/configure.ac
Expand Up @@ -1698,20 +1698,26 @@ if test "$_os" != "WINNT" -o "$WITH_MINGWIN" = "yes"; then
AC_PROG_CC
fi

if test "$_os" = "FreeBSD"; then
FBSD_GCC_RPATH=
dnl Clang detection on supported platforms
if test "$_os" = "Linux" -o "$_os" = "FreeBSD"; then
if $CC --version 2>&1 | $GREP clang > /dev/null ; then
COM_IS=CLANG
else
COM_IS=GCC
fi
AC_SUBST(COM_IS)
fi

if test "$_os" = "FreeBSD"; then
FBSD_GCC_RPATH=
if "$COM_IS" = "GCC"; then
rpath=`$CC --print-file-name libstdc++.so`
rpath=`realpath $rpath`
rpath=`dirname $rpath`
if test "$rpath" != "/usr/lib" ; then
FBSD_GCC_RPATH="-Wl,-rpath=$rpath"
fi
fi
AC_SUBST(COM_IS)
AC_SUBST(FBSD_GCC_RPATH)
fi

Expand Down

0 comments on commit bcc22a4

Please sign in to comment.