summaryrefslogtreecommitdiff
path: root/runtime/Makefile.libs
blob: 52766e16bfcec25758329df5e553d78c76baf07d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#                          test/Libraries/Makefile.libs
#
# This makefile should be used by subdirectories, which are libraries that are
# to be compiled to llvm bytecode and linked together with a specified name.
#
# Variables to be defined before including this makefile:
#
# 1. LEVEL - Must be set as per normal semantics: The depth from the top of tree
# 2. LIBNAME - Name of library to link together.  Forms lib<LIBNAME>.bc
# 3. EXPORTED_SYMBOL_LIST - If this symbol is defined, it contains a comma
#    separated list of symbols that are exported by the library.  All other
#    symbols are marked internal, reducing namespace pollution.
#

DESTLIBDIR  := $(LEVEL)/test/Libraries/Output
DESTLIBNAME := $(LEVEL)/test/Libraries/Output/lib$(LIBNAME).bc

all:: $(DESTLIBNAME)

include $(LEVEL)/test/Makefile.tests

# Figure out what object files we want to build...
LObjs    := $(sort $(addsuffix .bc, $(basename $(Source))))
LObjects := $(addprefix Output/,$(LObjs))

.PRECIOUS: $(LObjects)

# If the library specified a list of symbols to export, add an internalize pass
# to the link options.
ifdef EXPORTED_SYMBOL_LIST
LLINK_OPTS += -internalize -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
endif

# Standard set of postlink optimizations...
LLINK_OPTS +=  -inline -globaldce -funcresolve -deadtypeelim -instcombine -simplifycfg

# Link the library, then perform postlink optimization...
$(DESTLIBNAME): $(DESTLIBDIR)/.dir $(LObjects) $(LLINK) $(LOPT)
	$(LLINK) -f $(LObjects) $(LDFLAGS) | \
	 $(LOPT) -f -q $(LLINK_OPTS) -o $@

# Install target for libraries: Copy into the gcc install directory.
#
INSTALL_DIR := $(LLVMGCCDIR)/bytecode-libs/

install:: $(DESTLIBNAME)
	cp $(DESTLIBNAME) $(INSTALL_DIR)