fix GCC 4.6 LTO build

On Ubuntu 11.10, the optimized build was breaking, apparently because
it was eliminating most of the symbols defined in assembly code
(e.g. vmJump) as unreachable when linking libjvm.so, which left
avian-dynamic unlinkable due to an unresolved symbol.

The solution in this commit is to export makeSystem and makeFinder
from libjvm.so rather than build redundant versions of finder.cpp and
posix.cpp/windows.cpp into avian-dynamic like we've been doing.  This
avoids the whole problem of vmJump reachability and reduces the size
of avian-dynamic at the same time.

This commit also turns off LTO for the avian-dynamic link since we get
odd undefined symbol errors about libc-defined symbols otherwise.
This may merit future investigation, but avian-dynamic is so small and
simple that there's no need to optimize it anyway.
This commit is contained in:
Joel Dice 2011-11-19 19:26:25 -07:00
parent b29db7fece
commit 1c85ea8a6e
4 changed files with 8 additions and 7 deletions

View File

@ -447,6 +447,7 @@ ifeq ($(use-lto),true)
ifeq ($(shell expr 4 \< $(gcc-major) \
\| \( 4 \<= $(gcc-major) \& 6 \<= $(gcc-minor) \)),1)
optimization-cflags += -flto
no-lto = -fno-lto
lflags += $(optimization-cflags)
endif
endif
@ -588,9 +589,7 @@ lflags += $(extra-lflags)
driver-source = $(src)/main.cpp
driver-object = $(build)/main.o
driver-dynamic-objects = \
$(build)/main-dynamic.o \
$(build)/$(system).o \
$(build)/finder.o
$(build)/main-dynamic.o
boot-source = $(src)/boot.cpp
boot-object = $(build)/boot.o
@ -958,6 +957,8 @@ else
endif
$(strip) $(strip-all) $(@)
# todo: the $(no-lto) flag below is due to odd undefined reference errors on
# Ubuntu 11.10 which may be fixable without disabling LTO.
$(executable-dynamic): $(driver-dynamic-objects) $(dynamic-library)
@echo "linking $(@)"
ifdef msvc
@ -966,7 +967,7 @@ ifdef msvc
-MANIFESTFILE:$(@).manifest
$(mt) -manifest $(@).manifest -outputresource:"$(@);1"
else
$(ld) $(driver-dynamic-objects) -L$(build) -ljvm $(lflags) -o $(@)
$(ld) $(driver-dynamic-objects) -L$(build) -ljvm $(lflags) $(no-lto) -o $(@)
endif
$(strip) $(strip-all) $(@)

View File

@ -920,7 +920,7 @@ class MyFinder: public Finder {
namespace vm {
Finder*
JNIEXPORT Finder*
makeFinder(System* s, Allocator* a, const char* path, const char* bootLibrary)
{
return new (a->allocate(sizeof(MyFinder))) MyFinder(s, a, path, bootLibrary);

View File

@ -999,7 +999,7 @@ handleSignal(int signal, siginfo_t*, void* context)
namespace vm {
System*
JNIEXPORT System*
makeSystem(const char*)
{
return new (malloc(sizeof(MySystem))) MySystem();

View File

@ -986,7 +986,7 @@ handleException(LPEXCEPTION_POINTERS e)
namespace vm {
System*
JNIEXPORT System*
makeSystem(const char* crashDumpDirectory)
{
return new (malloc(sizeof(MySystem))) MySystem(crashDumpDirectory);