Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/cmd/cgo/internal/testcshared/cshared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,3 +942,29 @@ func TestIssue68411(t *testing.T) {
t.Error("missing functions")
}
}

func TestSymbolicFunctions(t *testing.T) {
// Test that we can build a c-shared library with -Wl,-Bsymbolic-functions,
// see issue 80632.
globalSkip(t)
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
testenv.MustHaveBuildMode(t, "c-shared")
if GOOS != "linux" {
t.Skip("Skipping on non-Linux OS")
}

t.Parallel()

tmpdir := t.TempDir()
libname := filepath.Join(tmpdir, "libbsymbolic.a")

run(t,
nil,
"go", "build",
"-buildmode=c-shared",
"-installsuffix", "testcshared",
"-ldflags=-extldflags=-Wl,-Bsymbolic-functions",
"-o", libname, "./libgo",
)
}
3 changes: 2 additions & 1 deletion src/cmd/compile/internal/ssa/_gen/MIPS64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@
(Leq64U x y) => (XOR (MOVVconst [1]) (SGTU x y))

(OffPtr [off] ptr:(SP)) && is32Bit(off) => (MOVVaddr [int32(off)] ptr)
(OffPtr [off] ptr) => (ADDVconst [off] ptr)
(OffPtr [off] ptr) && is32Bit(off) => (ADDVconst [off] ptr)
(OffPtr [off] ptr) && !is32Bit(off) => (ADDV ptr (MOVVconst <typ.UInt64> [off]))

(Addr {sym} base) => (MOVVaddr {sym} base)
(LocalAddr <t> {sym} base mem) && t.Elem().HasPointers() => (MOVVaddr {sym} (SPanchored base mem))
Expand Down
24 changes: 13 additions & 11 deletions src/cmd/compile/internal/ssa/_gen/RISCV64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -622,17 +622,19 @@
(MOVBUreg x:(Select0 (LoweredAtomicCas64 _ _ _ _))) => (MOVDreg x)

// Avoid sign extension after word arithmetic.
(MOVWreg x:(ADDIW _)) => (MOVDreg x)
(MOVWreg x:(SUBW _ _)) => (MOVDreg x)
(MOVWreg x:(NEGW _)) => (MOVDreg x)
(MOVWreg x:(MULW _ _)) => (MOVDreg x)
(MOVWreg x:(DIVW _ _)) => (MOVDreg x)
(MOVWreg x:(DIVUW _ _)) => (MOVDreg x)
(MOVWreg x:(REMW _ _)) => (MOVDreg x)
(MOVWreg x:(REMUW _ _)) => (MOVDreg x)
(MOVWreg x:(ROLW _ _)) => (MOVDreg x)
(MOVWreg x:(RORW _ _)) => (MOVDreg x)
(MOVWreg x:(RORIW _)) => (MOVDreg x)
// Careful to not omit the sign extension in cases where regalloc
// might restore without it, see issue 80577.
(MOVWreg x:(ADDIW _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(SUBW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(NEGW _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(MULW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(DIVW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(DIVUW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(REMW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(REMUW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(ROLW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(RORW _ _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)
(MOVWreg x:(RORIW _)) && (x.Type.Size() == 8 || (x.Type.Size() == 4 && x.Type.IsSigned())) => (MOVDreg x)

// Fold double extensions.
(MOVBreg x:(MOVBreg _)) => (MOVDreg x)
Expand Down
Loading
Loading