Skip to content

Inconsistency between bazel and setuptools builds of CPython extension module. #28261

Description

@mitchallain

The CPython extension module build configuration should provide extra_compile_args=["-fvisibility=hidden"] to be equivalent to the Bazel build and to prevent upb symbols leaking into the public interface of the Python extension module. This can create segfaults for applications linking against libprotobuf.so which have duplicate upb symbols and duplicate extension registries

ext_modules=[
Extension(
'google._upb._message',
srcs,
include_dirs=[current_dir, os.path.join(current_dir, 'utf8_range')],
language='c',
extra_link_args=extra_link_args,
)

The Bazel configuration (note copts):

cc_binary(
name = name + "_binary",
srcs = srcs,
copts = copts + ["-fvisibility=hidden"],
linkopts = selects.with_or({
(
"//python/dist:osx_x86_64",
"//python/dist:osx_aarch64",
): ["-Wl,-undefined,dynamic_lookup"],
"//python/dist:windows_x86_32": ["-static-libgcc"],
"//conditions:default": [],
}),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions