1

work-around res_search on older glibcs

`res_search` became a proper symbol only in glibc 2.34. Until that it
was re-defined in headers, hitting the (in-)famous
https://github.com/ziglang/zig/issues/9485

glibc 2.34+:

    resolv/resolv.h:int             res_search (const char *, int, int, unsigned char *, int)

Old glibc:

    resolv/resolv.h:#define res_search              __res_search

Also, remove the toplevel includes, as they should never be included in
the first place: the headers are included explicitly when needed.
This commit is contained in:
Motiejus Jakštys
2023-01-18 15:42:39 +02:00
parent 90f6c07178
commit 7b0de33070
5 changed files with 52 additions and 32 deletions

View File

@@ -17,9 +17,6 @@ def declare_cc_toolchains(os, zig_sdk_path):
zigtarget = target_config.zigtarget
cxx_builtin_include_directories = []
for d in getattr(target_config, "toplevel_include", []):
cxx_builtin_include_directories.append(zig_sdk_path + "/" + d)
absolute_tool_paths = {}
for name, path in target_config.tool_paths.items() + DEFAULT_TOOL_PATHS:
if path[0] == "/":

View File

@@ -121,9 +121,15 @@ def _target_windows(gocpu, zigcpu):
def _target_linux_gnu(gocpu, zigcpu, glibc_version):
glibc_suffix = "gnu.{}".format(glibc_version)
# https://github.com/ziglang/zig/issues/5882#issuecomment-888250676
# fcntl_hack is only required for glibc 2.27 or less.
fcntl_hack = glibc_version < "2.28"
compiler_extra_includes = []
linker_version_scripts = []
if glibc_version < "2.28":
# https://github.com/ziglang/zig/issues/5882#issuecomment-888250676
compiler_extra_includes.append("glibc-hacks/fcntl.h")
linker_version_scripts.append("glibc-hacks/fcntl.map")
if glibc_version < "2.34":
compiler_extra_includes.append("glibc-hacks/res_search.h")
linker_version_scripts.append("glibc-hacks/res_search.map")
return struct(
gotarget = "linux_{}_{}".format(gocpu, glibc_suffix),
@@ -137,9 +143,8 @@ def _target_linux_gnu(gocpu, zigcpu, glibc_version):
(["libc/include/{}-linux-any".format(zigcpu)] if zigcpu != "x86_64" else []) + [
"libc/include/any-linux-any",
] + _INCLUDE_TAIL,
toplevel_include = ["glibc-hacks"] if fcntl_hack else [],
compiler_extra_includes = ["glibc-hacks/glibchack-fcntl.h"] if fcntl_hack else [],
linker_version_scripts = ["glibc-hacks/fcntl.map"] if fcntl_hack else [],
compiler_extra_includes = compiler_extra_includes,
linker_version_scripts = linker_version_scripts,
dynamic_library_linkopts = [],
copts = [],
libc = "glibc",