File tree Expand file tree Collapse file tree 5 files changed +34
-11
lines changed Expand file tree Collapse file tree 5 files changed +34
-11
lines changed Original file line number Diff line number Diff line change 11src
22include
3- libunwind.a
3+ libunwind * .a
44* .o
Original file line number Diff line number Diff line change 1+ SUFFIX ?=
2+ CPPFLAGS ?=
3+
4+ OUTLIB := libunwind$(SUFFIX ) .a
5+
16CC := clang
27CXX := clang++
38AR := llvm-ar
@@ -9,20 +14,25 @@ S_OBJLIST := UnwindRegistersRestore.o UnwindRegistersSave.o
914
1015CFLAGS := -std=c99
1116CXXFLAGS := -std=c++11 -nostdinc++ -fno-exceptions -fno-rtti
12- CPPFLAGS := -target mipsel-unknown-unknown -mcpu=mips2 -msingle-float \
13- -fstrict-aliasing -funwind-tables -O3 \
17+ CPPFLAGS := $( CPPFLAGS ) -target mipsel-unknown-unknown -mcpu=mips2 \
18+ -msingle-float - fstrict-aliasing -funwind-tables -O3 \
1419 -D __LITTLE_ENDIAN__ -D __ELF__ -D _LIBUNWIND_IS_BAREMETAL \
1520 -D _LIBUNWIND_HAS_NO_THREADS -D _LIBUNWIND_IS_NATIVE_ONLY \
1621 -DNDEBUG \
1722 -I /usr/local/pspdev/psp/include/ \
1823 -I include
1924
20- ../psp/libunwind.a : libunwind.a
21- cp libunwind.a ../psp/
25+ all :
26+ make ../psp/libunwind.a
27+ SUFFIX=_lto CPPFLAGS=-flto make ../psp/libunwind_lto.a
28+
29+ ../psp/$(OUTLIB ) : $(OUTLIB )
30+ cp $^ ../psp/
2231 touch ../psp/build.rs
32+ make clean
2333
24- libunwind.a : $(CPP_OBJLIST ) $(C_OBJLIST ) $(S_OBJLIST )
25- $(AR ) $(ARFLAGS ) libunwind.a $^
34+ $( OUTLIB ) : $(CPP_OBJLIST ) $(C_OBJLIST ) $(S_OBJLIST )
35+ $(AR ) $(ARFLAGS ) $( OUTLIB ) $^
2636
2737$(CPP_OBJLIST ) : % .o: src/% .cpp
2838 $(COMPILE.cc ) $^
@@ -32,7 +42,7 @@ $(S_OBJLIST): %.o: src/%.S
3242$(C_OBJLIST ) $(S_OBJLIST ) :
3343 $(COMPILE.c ) $^
3444
35- .PHONY : clean patch
45+ .PHONY : all clean patch
3646
3747patch :
3848 git submodule update --init --depth 1 -- ./rustc
4151 patch -p0 < ./no-sdc1.patch
4252
4353clean :
44- rm -r * .o libunwind.a
54+ rm -r * .o
Original file line number Diff line number Diff line change 1- use std:: { env, path:: Path } ;
1+ use std:: { env, path:: Path , os :: unix :: prelude :: OsStrExt } ;
22
33fn main ( ) {
44 println ! ( "cargo:rerun-if-changed=build.rs" ) ;
55 println ! ( "cargo:rerun-if-changed=libunwind.a" ) ;
6+ println ! ( "cargo:rerun-if-env-changed=RUSTFLAGS" ) ;
67
78 if env:: var ( "CARGO_FEATURE_STUB_ONLY" ) . is_ok ( ) {
89 return ;
910 }
1011
12+ // Figure out whether to use the LTO libunwind, or the regular one.
13+ let libunwind = if env:: var_os ( "CARGO_ENCODED_RUSTFLAGS" )
14+ . expect ( "could not get `CARGO_ENCODED_RUSTFLAGS` variable" )
15+ . as_bytes ( )
16+ . split ( |b| * b == 0x1f )
17+ . any ( |flags| flags. starts_with ( b"-Clinker-plugin-lto" ) )
18+ {
19+ "./libunwind_lto.a"
20+ } else {
21+ "./libunwind.a"
22+ } ;
23+
1124 // TODO: Do we even need to copy the library over? Maybe we can just link
1225 // directly from the current directory.
1326 let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
1427 let out_file = Path :: new ( & out_dir) . join ( "libunwind.a" ) ;
15- std:: fs:: copy ( "./ libunwind.a" , out_file) . unwrap ( ) ;
28+ std:: fs:: copy ( libunwind, out_file) . unwrap ( ) ;
1629
1730 println ! ( "cargo:rustc-link-lib=static=unwind" ) ;
1831 println ! ( "cargo:rustc-link-search=native={}" , out_dir) ;
You can’t perform that action at this time.
0 commit comments