File: sysroot2.sh

package info (click to toggle)
mold 2.37.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 43,640 kB
  • sloc: ansic: 190,908; cpp: 153,224; asm: 29,233; sh: 13,504; python: 4,247; makefile: 3,322; ada: 1,681; pascal: 1,139; xml: 278; objc: 176; javascript: 37
file content (44 lines) | stat: -rwxr-xr-x 739 bytes parent folder | download
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
#!/bin/bash
. $(dirname $0)/common.inc

[[ $MACHINE = loongarch* ]] && skip

mkdir -p $t/bin $t/sysroot/foo

cat <<EOF > $t/a.script
INPUT(=/foo/x.o)
EOF

cat <<EOF > $t/sysroot/b.script
INPUT(/foo/y.o)
EOF

cat <<EOF | $CC -c -o $t/sysroot/foo/x.o -xc -
#include <stdio.h>
void hello() {
  printf("Hello world\n");
}
EOF

cat <<EOF | $CC -c -o $t/sysroot/foo/y.o -xc -
#include <stdio.h>
void hello2() {
  printf("Hello world\n");
}
EOF

cat <<EOF | $CC -c -o $t/c.o -xc -
void hello();
void hello2();

int main() {
  hello();
  hello2();
}
EOF

$CC -B. -o $t/exe -Wl,--sysroot=$t/sysroot \
  $t/a.script $t/sysroot/b.script $t/c.o

$CC -B. -o $t/exe -Wl,--sysroot=$(realpath $t)/bin/../sysroot \
  $t/a.script $t/sysroot/b.script $t/c.o