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 1
1
src
2
2
include
3
- libunwind.a
3
+ libunwind * .a
4
4
* .o
Original file line number Diff line number Diff line change
1
+ SUFFIX ?=
2
+ CPPFLAGS ?=
3
+
4
+ OUTLIB := libunwind$(SUFFIX ) .a
5
+
1
6
CC := clang
2
7
CXX := clang++
3
8
AR := llvm-ar
@@ -9,20 +14,25 @@ S_OBJLIST := UnwindRegistersRestore.o UnwindRegistersSave.o
9
14
10
15
CFLAGS := -std=c99
11
16
CXXFLAGS := -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 \
14
19
-D __LITTLE_ENDIAN__ -D __ELF__ -D _LIBUNWIND_IS_BAREMETAL \
15
20
-D _LIBUNWIND_HAS_NO_THREADS -D _LIBUNWIND_IS_NATIVE_ONLY \
16
21
-DNDEBUG \
17
22
-I /usr/local/pspdev/psp/include/ \
18
23
-I include
19
24
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/
22
31
touch ../psp/build.rs
32
+ make clean
23
33
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 ) $^
26
36
27
37
$(CPP_OBJLIST ) : % .o: src/% .cpp
28
38
$(COMPILE.cc ) $^
@@ -32,7 +42,7 @@ $(S_OBJLIST): %.o: src/%.S
32
42
$(C_OBJLIST ) $(S_OBJLIST ) :
33
43
$(COMPILE.c ) $^
34
44
35
- .PHONY : clean patch
45
+ .PHONY : all clean patch
36
46
37
47
patch :
38
48
git submodule update --init --depth 1 -- ./rustc
41
51
patch -p0 < ./no-sdc1.patch
42
52
43
53
clean :
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 } ;
2
2
3
3
fn main ( ) {
4
4
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
5
5
println ! ( "cargo:rerun-if-changed=libunwind.a" ) ;
6
+ println ! ( "cargo:rerun-if-env-changed=RUSTFLAGS" ) ;
6
7
7
8
if env:: var ( "CARGO_FEATURE_STUB_ONLY" ) . is_ok ( ) {
8
9
return ;
9
10
}
10
11
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
+
11
24
// TODO: Do we even need to copy the library over? Maybe we can just link
12
25
// directly from the current directory.
13
26
let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
14
27
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 ( ) ;
16
29
17
30
println ! ( "cargo:rustc-link-lib=static=unwind" ) ;
18
31
println ! ( "cargo:rustc-link-search=native={}" , out_dir) ;
You can’t perform that action at this time.
0 commit comments