From nobody Thu Jul 07 10:24:58 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 165A812AD0E5; Thu, 7 Jul 2022 10:24:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ldswp2xplz3Jg9; Thu, 7 Jul 2022 10:24:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657189498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=R94MbecLvvnITItEf1NXTy3VJWQZgtKftkUAUZNhLsA=; b=KGveugVrOF0UT+rcYqtoMxUmXyqkJpluphOUJIm+WNkYR01rjDFGYd9a2KlckooZn7duyW gHj+3qnhy4ShTBTiHgbWUTAhzVThhWm0ku8FYFHu2tBquNhKrzFoXJcJYbJ+pcINIFAXsg W1yqf9YdYMWFQyGH+pz9mThP/wjQzU4rMtpNce51u0Kg2zMxvAAWwyL50Lj562ubpA8KiO qrYs9q9tVc/Vm2/zBvXVa5AiwflgYti6ukYRvKcObAb+pakXwmCfiKF+0oI4/BkTXkXTUa uM9dAoyz2Q4Z4+LCzOFdR30Akrpyzxu4XDB3Ixy/s0PWKsaIWAufqM6hB+kORg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Ldswp1Lgkzg03; Thu, 7 Jul 2022 10:24:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 267AOwj7094831; Thu, 7 Jul 2022 10:24:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 267AOwWD094830; Thu, 7 Jul 2022 10:24:58 GMT (envelope-from git) Date: Thu, 7 Jul 2022 10:24:58 GMT Message-Id: <202207071024.267AOwWD094830@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Gleb Popov Subject: git: be5f5db25099 - main - lang/ghc: Add RTS linker patch for the external interpreter. List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: be5f5db250995bdf3b4fa02b0ea958a0cf838f66 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657189498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=R94MbecLvvnITItEf1NXTy3VJWQZgtKftkUAUZNhLsA=; b=ds8iCxhP/NmY4RwpDDyLjOMOhreCAbDjflkcQTPwjdKEFXu/iVQvhCbraJvmJ/NtpzhrRS P+AjexKukFUl4Mzkh52j4Vhk2UktjjhaiJfi37ps4e1OgXlz4jCat4YALk+BwNtXqjuJQE 4hEfeNGH2geYCDv45UbglEzY+mElZSuaiOR4DCQPgDXp8Hf94r3kjJ90OxJGcxu/AkjA61 FvJS48bw3FrEka0J+bK5/RX3QQ1BWS4APwPZDYh+9E4sSz4pId7pfO8lOgjjn4HA5ubkha 5mTOgGFVDDjL1bE7O48wtxWqwKCbQ3QfzLh+H09ksso7hy6vz1i1Bu6iml+5XA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657189498; a=rsa-sha256; cv=none; b=SoW6JkAGrbaWaoM4Kncxp4gvtHbic2LqTq6j9gUWAHd+UoUuF7gCDlkHLZKuCTnUdOAhOI XxCJWYJkXECcRgv1dd65KuiRxifu75uXCg/Z/2jhs9luEZ6kfy5iZKWIbpRy5OtSY1ygCU +XmsO6okLrj0Zs9thJwV87K2dpB9JxCIEt+nr6W5rVcorRz6CtpayLIWnoZezOaW7de4tl 2ySdtBBzL/OF4CdiB1wOFic0bNQYc1D9J+HU9defJpxNhR005VEx0OMYYZp8HyVYlx4snJ NggazZlTfhqeN0pfdeb6A4j65s6B2llsQ8zmwTUT7DNmUGL0BjtfC5oZT66YVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by arrowd: URL: https://cgit.FreeBSD.org/ports/commit/?id=be5f5db250995bdf3b4fa02b0ea958a0cf838f66 commit be5f5db250995bdf3b4fa02b0ea958a0cf838f66 Author: Gleb Popov AuthorDate: 2021-12-29 09:12:27 +0000 Commit: Gleb Popov CommitDate: 2022-07-07 10:24:10 +0000 lang/ghc: Add RTS linker patch for the external interpreter. --- lang/ghc/files/patch-rts-linker | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/lang/ghc/files/patch-rts-linker b/lang/ghc/files/patch-rts-linker new file mode 100644 index 000000000000..feb736f72176 --- /dev/null +++ b/lang/ghc/files/patch-rts-linker @@ -0,0 +1,87 @@ +diff --git a/rts/Linker.c b/rts/Linker.c +index 72533ae52af48184fb76171fb93a73c04d025f2f..09cf5fa0593743f9b9f44603e2290cea9132ed89 100644 +--- rts/Linker.c ++++ rts/Linker.c +@@ -78,6 +78,33 @@ + #if defined(dragonfly_HOST_OS) + #include + #endif ++ ++/* ++ * Note [iconv and FreeBSD] ++ * ~~~~~~~~~~~~~~~~~~~~~~~~ ++ * ++ * On FreeBSD libc.so provides an implementation of the iconv_* family of ++ * functions. However, due to their implementation, these symbols cannot be ++ * resolved via dlsym(); rather, they can only be resolved using the ++ * explicitly-versioned dlvsym(). ++ * ++ * This is problematic for the RTS linker since we may be asked to load ++ * an object that depends upon iconv. To handle this we include a set of ++ * fallback cases for these functions, allowing us to resolve them to the ++ * symbols provided by the libc against which the RTS is linked. ++ * ++ * See #20354. ++ */ ++ ++#if defined(freebsd_HOST_OS) ++extern void iconvctl(); ++extern void iconv_open_into(); ++extern void iconv_open(); ++extern void iconv_close(); ++extern void iconv_canonicalize(); ++extern void iconv(); ++#endif ++ + /* + Note [runtime-linker-support] + ----------------------------- +@@ -655,6 +682,10 @@ internal_dlsym(const char *symbol) { + } + RELEASE_LOCK(&dl_mutex); + ++ IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in special cases\n", symbol)); ++# define SPECIAL_SYMBOL(sym) \ ++ if (strcmp(symbol, #sym) == 0) return (void*)&sym; ++ + # if defined(HAVE_SYS_STAT_H) && defined(linux_HOST_OS) && defined(__GLIBC__) + // HACK: GLIBC implements these functions with a great deal of trickery where + // they are either inlined at compile time to their corresponding +@@ -664,18 +695,28 @@ internal_dlsym(const char *symbol) { + // We borrow the approach that the LLVM JIT uses to resolve these + // symbols. See http://llvm.org/PR274 and #7072 for more info. + +- IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in GLIBC special cases\n", symbol)); ++ SPECIAL_SYMBOL(stat); ++ SPECIAL_SYMBOL(fstat); ++ SPECIAL_SYMBOL(lstat); ++ SPECIAL_SYMBOL(stat64); ++ SPECIAL_SYMBOL(fstat64); ++ SPECIAL_SYMBOL(lstat64); ++ SPECIAL_SYMBOL(atexit); ++ SPECIAL_SYMBOL(mknod); ++# endif + +- if (strcmp(symbol, "stat") == 0) return (void*)&stat; +- if (strcmp(symbol, "fstat") == 0) return (void*)&fstat; +- if (strcmp(symbol, "lstat") == 0) return (void*)&lstat; +- if (strcmp(symbol, "stat64") == 0) return (void*)&stat64; +- if (strcmp(symbol, "fstat64") == 0) return (void*)&fstat64; +- if (strcmp(symbol, "lstat64") == 0) return (void*)&lstat64; +- if (strcmp(symbol, "atexit") == 0) return (void*)&atexit; +- if (strcmp(symbol, "mknod") == 0) return (void*)&mknod; ++ // See Note [iconv and FreeBSD] ++# if defined(freebsd_HOST_OS) ++ SPECIAL_SYMBOL(iconvctl); ++ SPECIAL_SYMBOL(iconv_open_into); ++ SPECIAL_SYMBOL(iconv_open); ++ SPECIAL_SYMBOL(iconv_close); ++ SPECIAL_SYMBOL(iconv_canonicalize); ++ SPECIAL_SYMBOL(iconv); + # endif + ++#undef SPECIAL_SYMBOL ++ + // we failed to find the symbol + return NULL; + }