fune/build/moz.configure/libraries.configure
serge-sans-paille a1106cbc85 Bug 1883720 - (re)Move checks for socket, gethostbyname_r and demangle to moz.configure r=glandium
Actually remove the check for demangle, no supported target need that
check.

Also make library dependencies explicit instead of relying on "$LIBS".

Differential Revision: https://phabricator.services.mozilla.com/D203637
2024-05-17 07:35:09 +00:00

87 lines
2.7 KiB
Python

# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@template
def check_clock_monotonic_support(lib=None, when=None):
check_msg = "for clock_gettime(CLOCK_MONOTONIC)"
flags = []
if lib is not None:
check_msg += f" in {lib}"
flags.append(f"-l{lib}")
check_when = building_with_gnu_cc
if when is not None:
check_when &= when
return try_link(
includes=["time.h"],
body="struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);",
check_msg=check_msg,
flags=flags,
when=check_when,
)
have_raw_clock_monotonic_support = check_clock_monotonic_support()
have_rt_clock_monotonic_support = check_clock_monotonic_support(
lib="rt", when=~have_raw_clock_monotonic_support
)
set_define(
"HAVE_CLOCK_MONOTONIC",
have_raw_clock_monotonic_support | have_rt_clock_monotonic_support,
)
set_config(
"HAVE_CLOCK_MONOTONIC",
have_raw_clock_monotonic_support | have_rt_clock_monotonic_support,
)
set_config("REALTIME_LIBS", ["-lrt"], when=have_rt_clock_monotonic_support)
have_res_ninit = try_link(
includes=["sys/types.h", "netinet/in.h", "arpa/nameser.h", "resolv.h"],
body="int foo = res_ninit(&_res);",
check_msg="for res_ninit()",
flags=depends(when=building_linux)(["-D_BSD_SOURCE=1"]),
when=building_with_gnu_cc & ~target_is_netbsd & ~target_is_openbsd,
)
set_define("HAVE_RES_NINIT", have_res_ninit)
# We don't want to link with libdl even if it's present on OS X, since
# it's not used and not part of the default installation.
# We don't want to link against libm or libpthread on Darwin since
# they both are just symlinks to libSystem and explicitly linking
# against libSystem causes issues when debugging (see bug 299601).
with only_when(building_with_gnu_cc):
dladdr_check = check_symbol_in_libs([None, "dl"], symbol="dladdr")
set_define(
"HAVE_DLADDR", depends(dladdr_check)(lambda check: "1" if check.found else "0")
)
with only_when(~target_is_darwin):
check_header("dlfcn.h")
dlopen_check = check_symbol_in_libs(["dl", None], symbol="dlopen")
set_config(
"DL_LIBS", ["-ldl"], when=depends(dlopen_check)(lambda check: check.lib)
)
set_config(
"C_R_LIBS",
["-lc_r"],
when=check_symbol_in_lib(
"c_r", symbol="gethostbyname_r", when=building_with_gnu_cc
),
)
set_config(
"SOCKET_LIBS",
["-lsocket"],
when=check_symbol_in_lib("socket", symbol="socket", when=building_with_gnu_cc),
)