Skip to content

Commit

Permalink
for s390x arch the auto generated objects need to have s390x prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
  • Loading branch information
msherif1234 committed Jan 16, 2024
1 parent a8be855 commit b384e80
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
50 changes: 25 additions & 25 deletions cmd/bpf2go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,26 @@ Options:
// Targets without a Linux string can't be used directly and are only included
// for the generic bpf, bpfel, bpfeb targets.
var targetByGoArch = map[string]target{
"386": {"bpfel", "x86"},
"amd64": {"bpfel", "x86"},
"amd64p32": {"bpfel", ""},
"arm": {"bpfel", "arm"},
"arm64": {"bpfel", "arm64"},
"loong64": {"bpfel", "loongarch"},
"mipsle": {"bpfel", ""},
"mips64le": {"bpfel", ""},
"mips64p32le": {"bpfel", ""},
"ppc64le": {"bpfel", "powerpc"},
"riscv64": {"bpfel", "riscv"},
"armbe": {"bpfeb", "arm"},
"arm64be": {"bpfeb", "arm64"},
"mips": {"bpfeb", ""},
"mips64": {"bpfeb", ""},
"mips64p32": {"bpfeb", ""},
"ppc64": {"bpfeb", "powerpc"},
"s390": {"bpfeb", "s390"},
"s390x": {"bpfeb", "s390"},
"sparc": {"bpfeb", "sparc"},
"sparc64": {"bpfeb", "sparc"},
"386": {"bpfel", "x86", "x86"},
"amd64": {"bpfel", "x86", "x86"},
"amd64p32": {"bpfel", "", ""},
"arm": {"bpfel", "arm", "arm"},
"arm64": {"bpfel", "arm64", "arm64"},
"loong64": {"bpfel", "loongarch", "loongarch"},
"mipsle": {"bpfel", "", ""},
"mips64le": {"bpfel", "", ""},
"mips64p32le": {"bpfel", "", ""},
"ppc64le": {"bpfel", "powerpc", "powerpc"},
"riscv64": {"bpfel", "riscv", "riscv"},
"armbe": {"bpfeb", "arm", "arm"},
"arm64be": {"bpfeb", "arm64", "arm64"},
"mips": {"bpfeb", "", ""},
"mips64": {"bpfeb", "", ""},
"mips64p32": {"bpfeb", "", ""},
"ppc64": {"bpfeb", "powerpc", "powerpc"},
"s390x": {"bpfeb", "s390", "s390x"},
"sparc": {"bpfeb", "sparc", "sparc"},
"sparc64": {"bpfeb", "sparc", "sparc"},
}

func run(stdout io.Writer, pkg, outputDir string, args []string) (err error) {
Expand Down Expand Up @@ -312,7 +311,7 @@ func (b2g *bpf2go) convert(tgt target, arches []string) (err error) {
}
stem := fmt.Sprintf("%s_%s", outputStem, tgt.clang)
if tgt.linux != "" {
stem = fmt.Sprintf("%s_%s_%s", outputStem, tgt.clang, tgt.linux)
stem = fmt.Sprintf("%s_%s_%s", outputStem, tgt.clang, tgt.goarch)
}

objFileName := filepath.Join(b2g.outputDir, stem+".o")
Expand Down Expand Up @@ -419,8 +418,9 @@ func (b2g *bpf2go) convert(tgt target, arches []string) (err error) {
}

type target struct {
clang string
linux string
clang string
linux string
goarch string
}

func printTargets(w io.Writer) {
Expand Down Expand Up @@ -455,7 +455,7 @@ func collectTargets(targets []string) (map[target][]string, error) {
}
}
sort.Strings(goarches)
result[target{tgt, ""}] = goarches
result[target{tgt, "", ""}] = goarches

case "native":
tgt = runtime.GOARCH
Expand Down
18 changes: 12 additions & 6 deletions cmd/bpf2go/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,28 @@ func TestCollectTargets(t *testing.T) {
{
[]string{"bpf", "bpfel", "bpfeb"},
map[target][]string{
{"bpf", ""}: nil,
{"bpfel", ""}: clangArches["bpfel"],
{"bpfeb", ""}: clangArches["bpfeb"],
{"bpf", "", ""}: nil,
{"bpfel", "", ""}: clangArches["bpfel"],
{"bpfeb", "", ""}: clangArches["bpfeb"],
},
},
{
[]string{"amd64", "386"},
map[target][]string{
{"bpfel", "x86"}: linuxArchesLE["x86"],
{"bpfel", "x86", "x86"}: linuxArchesLE["x86"],
},
},
{
[]string{"amd64", "arm64be"},
map[target][]string{
{"bpfeb", "arm64"}: linuxArchesBE["arm64"],
{"bpfel", "x86"}: linuxArchesLE["x86"],
{"bpfeb", "arm64", "arm64"}: linuxArchesBE["arm64"],
{"bpfel", "x86", "x86"}: linuxArchesLE["x86"],
},
},
{
[]string{"s390x"},
map[target][]string{
{"bpfeb", "s390", "s390x"}: linuxArchesBE["s390"],
},
},
{
Expand Down

0 comments on commit b384e80

Please sign in to comment.