| OLD | NEW |
| (Empty) | |
| 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 # simple example(s) for builing shared images with the pnacl TC |
| 6 # which do not require glibc |
| 7 |
| 8 ROOT=$(shell readlink -f ../../) |
| 9 TC_ROOT=$(ROOT)/toolchain/pnacl_linux_x86_64/glibc |
| 10 PNACL_CC=$(TC_ROOT)/bin/pnacl-clang |
| 11 PNACL_LD=$(TC_ROOT)/bin/pnacl-nativeld |
| 12 |
| 13 BOOTER=$(ROOT)/scons-out/opt-linux-x86-32/staging/nacl_helper_bootstrap |
| 14 LOADER=$(ROOT)/scons-out/opt-linux-x86-32/staging/sel_ldr |
| 15 LDSO=$(ROOT)/toolchain/pnacl_linux_x86_64/lib-x86-32/runnable-ld.so |
| 16 LIBPATH_SHARED=$(ROOT)/toolchain/pnacl_linux_x86_64/lib-x86-32 |
| 17 PATH_CRT=$(ROOT)/toolchain/pnacl_linux_x86_64/glibc/lib |
| 18 PATH_CRT_SRC=$(ROOT)/pnacl/support |
| 19 |
| 20 COMMON_FLAGS= --pnacl-driver-verbose -save-temps |
| 21 |
| 22 RUNNER=$(BOOTER) $(LOADER) -S -E LD_DEBUG=all --r_debug=0xXXXXXXXXXXXXXXXX -a \ |
| 23 -- $(LDSO) --library-path $(LIBPATH_SHARED) |
| 24 |
| 25 |
| 26 ###################################################################### |
| 27 PNACL_CC_FLAGS = $(COMMON_FLAGS) |
| 28 |
| 29 hello1.bc: hello1.c |
| 30 $(PNACL_CC) -c $(PNACL_CC_FLAGS) -o $@ $^ |
| 31 |
| 32 fortytwo.bc: fortytwo.c |
| 33 $(PNACL_CC) -c $(PNACL_CC_FLAGS) -o $@ $^ |
| 34 |
| 35 crtbegin.bc: $(PATH_CRT_SRC)/crtbegin.c |
| 36 $(PNACL_CC) -c $(PNACL_CC_FLAGS) -o $@ $^ |
| 37 |
| 38 crtend.bc: $(PATH_CRT_SRC)/crtend.c |
| 39 $(PNACL_CC) -c $(PNACL_CC_FLAGS) -o $@ $^ |
| 40 |
| 41 # TODO(robertm): add soname and maybe go to pso first |
| 42 #libsimple.so: fortytwo.bc |
| 43 # $(PNACL_CC) $(COMMON_FLAGS) -nostdlib -shared -fPIC -arch x86-32 -o $@
$^ |
| 44 |
| 45 LIBS = -L $(LIBPATH_SHARED) -l:ld-2.9.so |
| 46 LD_FLAGS_NATIVE = --pnacl-allow-native -arch x86-32 |
| 47 # NOTE: the duplication of crtbegin.bc. |
| 48 # The one here was build from $(PATH_CRT_SRC)/bitcode |
| 49 # The one above from $(PATH_CRT_SRC) |
| 50 INIT = crtbegin.bc $(PATH_CRT)/crt1.bc $(PATH_CRT)/crti.bc $(PATH_CRT)/crtdummy
.bc $(PATH_CRT)/crtbegin.bc |
| 51 |
| 52 FINI = crtend.bc |
| 53 |
| 54 # we run this to steal the .o file |
| 55 # the nexe produced by this is unfortunately not a dynamic image |
| 56 # because of special handling of -l:ld-2.9.so which gets passed through as |
| 57 # --add-extra-dt-needed=ld-nacl-x86-32.so.1 which does not trigger the |
| 58 # a dynamic image |
| 59 hello1.x86-32.nexe.dummy: hello1.bc crtend.bc crtbegin.bc |
| 60 $(PNACL_CC) $(COMMON_FLAGS) $(LD_FLAGS_NATIVE) -nodefaultlibs -nostdlib
\ |
| 61 $(INIT) hello1.bc $(LIBS) $(FINI) -o $@ |
| 62 |
| 63 |
| 64 # here we steal the object file from hello1.x86-32.nexe.dummy |
| 65 hello1.x86-32.nexe: hello1.x86-32.nexe.dummy |
| 66 $(PNACL_LD) $(COMMON_FLAGS) -arch x86-32 $(LIBS) hello1.x86-32.nexe.du
mmy---linked.o -o $@ |
| 67 |
| 68 |
| 69 ###################################################################### |
| 70 |
| 71 run1: hello1.x86-32.nexe |
| 72 ${RUNNER} ./hello1.x86-32.nexe |
| 73 |
| 74 ###################################################################### |
| 75 |
| 76 clean: |
| 77 rm -f *.bc *.o *.ll *.so main *.pso *.raw |
| OLD | NEW |