Skip to content

Commit

Permalink
cmd/cgo: disable clang's integrated assembler
Browse files Browse the repository at this point in the history
Fixes golang#8348.

Clang's internal assembler (introduced by default in clang 3.4) understands the .arch directive, but doesn't change the default value of -march. This causes the build to fail when we use BLX (armv5 and above) when clang is compiled for the default armv4t architecture (which appears to be the default on all the distros I've used).

This is probably a clang bug, so work around it for the time being by disabling the integrated assembler when compiling the cgo assembly shim.

This CL also includes a small change to ldelf.c which was required as clang 3.4 and above generate more weird symtab entries.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/156430044
  • Loading branch information
davecheney authored and wheatman committed Jun 25, 2018
1 parent 8cc75fe commit 0f8c4b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/cmd/cgo/gcc.go
Expand Up @@ -745,7 +745,13 @@ func (p *Package) gccMachine() []string {
case "386":
return []string{"-m32"}
case "arm":
return []string{"-marm"} // not thumb
args := []string{"-marm"} // not thumb
if strings.Contains(p.gccBaseCmd()[0], "clang") {
// The clang integrated assembler understands the .arch directive
// but does not appear to honor it, so disable it. Issue 8348.
args = append(args, "-no-integrated-as")
}
return args
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ld/ldelf.c
Expand Up @@ -819,7 +819,7 @@ readsym(ElfObj *obj, int i, ElfSym *sym, int needSym)
}
break;
case ElfSymBindLocal:
if(!(thechar == '5' && (strcmp(sym->name, "$a") == 0 || strcmp(sym->name, "$d") == 0))) // binutils for arm generate these mapping symbols, ignore these
if(!(thechar == '5' && (strncmp(sym->name, "$a", 2) == 0 || strncmp(sym->name, "$d", 2) == 0))) // binutils for arm generate these mapping symbols, ignore these
if(needSym) {
// local names and hidden visiblity global names are unique
// and should only reference by its index, not name, so we
Expand Down

0 comments on commit 0f8c4b3

Please sign in to comment.