mirror of
https://github.com/golang/go
synced 2024-11-23 04:40:09 -07:00
cmd/link: add -extar option to set ar program for c-archive
People who want to use -buildmode=c-archive in unusual cross-compilation setups will need something like this. It could also be done via (yet another) environment variable but I use -extar by analogy with the existing -extld. Change-Id: I354cfabc4c470603affd13cd946997b3a24c0e6c Reviewed-on: https://go-review.googlesource.com/18913 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
c2b40809c1
commit
1aab7b9626
@ -85,4 +85,22 @@ if ! $bin; then
|
||||
fi
|
||||
rm -rf libgo4.a libgo4.h testp pkg
|
||||
|
||||
rm -f testar
|
||||
cat >testar <<EOF
|
||||
#!/usr/bin/env bash
|
||||
while expr \$1 : '[-]' >/dev/null; do
|
||||
shift
|
||||
done
|
||||
echo "testar" > \$1
|
||||
echo "testar" > $(pwd)/testar.ran
|
||||
EOF
|
||||
chmod +x testar
|
||||
rm -f testar.ran
|
||||
GOPATH=$(pwd) go build -buildmode=c-archive -ldflags=-extar=$(pwd)/testar -o libgo4.a libgo4
|
||||
if ! test -f testar.ran; then
|
||||
echo "FAIL test5"
|
||||
status=1
|
||||
fi
|
||||
rm -rf libgo4.a libgo4.h testar testar.ran pkg
|
||||
|
||||
exit $status
|
||||
|
@ -52,6 +52,9 @@ Flags:
|
||||
The dynamic header is on by default, even without any
|
||||
references to dynamic libraries, because many common
|
||||
system tools now assume the presence of the header.
|
||||
-extar ar
|
||||
Set the external archive program (default "ar").
|
||||
Used only for -buildmode=c-archive.
|
||||
-extld linker
|
||||
Set the external linker (default "clang" or "gcc").
|
||||
-extldflags flags
|
||||
|
@ -207,6 +207,7 @@ var (
|
||||
tmpdir string
|
||||
extld string
|
||||
extldflags string
|
||||
extar string
|
||||
libgccfile string
|
||||
debug_s int // backup old value of debug['s']
|
||||
Ctxt *Link
|
||||
@ -1015,8 +1016,12 @@ func archive() {
|
||||
return
|
||||
}
|
||||
|
||||
if extar == "" {
|
||||
extar = "ar"
|
||||
}
|
||||
|
||||
mayberemoveoutfile()
|
||||
argv := []string{"ar", "-q", "-c", "-s", outfile}
|
||||
argv := []string{extar, "-q", "-c", "-s", outfile}
|
||||
argv = append(argv, fmt.Sprintf("%s/go.o", tmpdir))
|
||||
argv = append(argv, hostobjCopy()...)
|
||||
|
||||
|
@ -89,6 +89,7 @@ func Ldmain() {
|
||||
flag.Var(&Buildmode, "buildmode", "set build `mode`")
|
||||
obj.Flagcount("c", "dump call graph", &Debug['c'])
|
||||
obj.Flagcount("d", "disable dynamic executable", &Debug['d'])
|
||||
obj.Flagstr("extar", "archive program for buildmode=c-archive", &extar)
|
||||
obj.Flagstr("extld", "use `linker` when linking in external mode", &extld)
|
||||
obj.Flagstr("extldflags", "pass `flags` to external linker", &extldflags)
|
||||
obj.Flagcount("f", "ignore version mismatch", &Debug['f'])
|
||||
|
Loading…
Reference in New Issue
Block a user