Skip to content

Commit fbbafef

Browse files
authored
Revert "Issue 1486: cgo: fix C++ dynamic initialization of static variables when using alwayslink = True (#4438)" (#4551)
This reverts commit 20f7e2b as it causes a regression (see #4548)
1 parent ebd809f commit fbbafef

File tree

9 files changed

+1
-116
lines changed

9 files changed

+1
-116
lines changed

CONTRIBUTORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# Names should be added to this file as:
1010
# Name <email address>
1111

12-
Andrei Reshetkov <enscogitans.v@gmail.com>
1312
Benjamin Staffin <benley@gmail.com>
1413
Brian Silverman <bsilver16384@gmail.com>
1514
Damien Martin-Guillerez <dmarting@google.com>

go/private/rules/cgo.bzl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def cgo_configure(go, srcs, cdeps, cppopts, copts, cxxopts, clinkopts):
9393
deps_direct = []
9494
lib_opts = []
9595
runfiles = go._ctx.runfiles(collect_data = True)
96-
seen_alwayslink_libs = {}
9796

9897
# Always include the sandbox as part of the build. Bazel does this, but it
9998
# doesn't appear in the CompilationContext.
@@ -146,13 +145,7 @@ def cgo_configure(go, srcs, cdeps, cppopts, copts, cxxopts, clinkopts):
146145
# libclntsh.dylib.12.1, users have to create a unversioned symbolic link,
147146
# so it can be treated as a simple shared library too.
148147
continue
149-
150-
if lib.basename.endswith(".lo") and lib.path not in seen_alwayslink_libs:
151-
seen_alwayslink_libs[lib.path] = True
152-
lib_opts.extend(_alwayslink_lib_opts(go, lib.path))
153-
else:
154-
lib_opts.append(lib.path)
155-
148+
lib_opts.append(lib.path)
156149
clinkopts.extend(cc_link_flags)
157150

158151
elif hasattr(d, "objc"):
@@ -209,11 +202,6 @@ def _cc_libs_and_flags(target):
209202
libs.append(library_to_link.dynamic_library)
210203
return libs, flags
211204

212-
def _alwayslink_lib_opts(go, lib_path):
213-
if go.mode.goos == "darwin":
214-
return ["-Wl,-force_load,{}".format(lib_path)]
215-
return ["-Wl,-whole-archive", lib_path, "-Wl,-no-whole-archive"]
216-
217205
def _include_unique(opts, flag, include, seen):
218206
if include in seen:
219207
return

tests/core/cgo/cgo_alwayslink_init/BUILD.bazel

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/core/cgo/cgo_alwayslink_init/README.rst

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/core/cgo/cgo_alwayslink_init/lib.cpp

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/core/cgo/cgo_alwayslink_init/lib.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/core/cgo/cgo_alwayslink_init/side_effect.cpp

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/core/cgo/cgo_alwayslink_init/test_side_effect.cpp

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/core/cgo/cgo_alwayslink_init/test_side_effect.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)