From nobody Sun Oct 10 04:41:30 2021 X-Original-To: freebsd-current@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 E57EC12DA4E8 for ; Sun, 10 Oct 2021 04:41:40 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HRq5J5QKnz4XJy for ; Sun, 10 Oct 2021 04:41:40 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-vs1-xe30.google.com with SMTP id a10so4698726vsr.1 for ; Sat, 09 Oct 2021 21:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LWOwROqc5K94yjeow2cxdA4ZI6G3gL7/t5ZrLeabvWQ=; b=uCCoIJss7XDmrj7ljPKoRQ3GqQoOcJt2priqAoctaQYgZ9luHtAxkButVQ0LUZ05jD 2RqMZIE2HIvOX+kSqOsCBBbASj5NNMTlpKsaEbyuJEP9OVq3+KghBXL49Zp9p446OfNS n/17h9w/YPdcEezSfvjU8EoxRzvH20qeCWPpDwfVhwFmEGedwKKefgpxG+EYzrG+WC+N V/IhbyYlrwtGRwPLIdN01fN2erLxSIw+zB8qVCFa09tTY5/RaaqqXVCUGWXBzSLppK+F D5xWdlxyH48QC66O9VFeuGIQL1NGESvcKKT56/7BK4S2aazjep4WzcTIG7zaVgz1a2pR K+EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LWOwROqc5K94yjeow2cxdA4ZI6G3gL7/t5ZrLeabvWQ=; b=MdLP90KHuGs7BizpFjvd/zcSDEtmpwiUG8v7DKrPQeecxe0HeyTn3A6DV2bW8aOSsb cd+Vpad7OxYy1YcV66zWz6HM+e9JHiVjYPn+YYeA2LOqda7ncoNSmWyTXTwKSFr/0AII e3OOE259kM6/BI0/bwAj0lf0L2hQPOK/l91Q+b6MU94j2Gsx9K7Kcc09uoLO9qcl2Cxo TpyUBOW8O0zrTOb7UbhdfJDmKsP4RXH76U8disObuKt1UaJYIlnG1s09bYV0EpmW9vsc K1e4rbGZI4bXwA+LbqCws0JGTPk4Erz31PvyX4ygGjDg8qPgN1XNAGYGDuctIQcFMDH9 55xQ== X-Gm-Message-State: AOAM532SHl3ebvWPNUHQBQjuiINrjAR24jm1MURFIZjBTumQQ0ElBlmF dvUtZTS+JKmx5y9BsQ+hdl0rJ9bTZfPL4AwitBgm3g== X-Google-Smtp-Source: ABdhPJxcn4YPTin+2MHn8kLTpKn0VvkhyKfqNBM0F3rKsabCftVsOpabgtMmYwLbmtkuJBNwr1tnDVsSv+W/L9l0HaI= X-Received: by 2002:a67:d28f:: with SMTP id z15mr18459848vsi.44.1633840894130; Sat, 09 Oct 2021 21:41:34 -0700 (PDT) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 References: <20211009094624.3f3cacc8@jelly.fritz.box> <2FCA108B-29E1-48EA-A8C7-BC621CC6F963@FreeBSD.org> <94E84785-8F8C-4E90-A437-929565F5C968@FreeBSD.org> <20211010040637.3fw7q6nl7gn7aum4@aniel.nours.eu> In-Reply-To: <20211010040637.3fw7q6nl7gn7aum4@aniel.nours.eu> From: Warner Losh Date: Sat, 9 Oct 2021 22:41:30 -0600 Message-ID: Subject: Re: clang/llvm-tblgen --- ld: error: undefined symbol: setupterm To: Baptiste Daroussin Cc: Konstantin Belousov , Dimitry Andric , FreeBSD User , FreeBSD CURRENT Content-Type: multipart/alternative; boundary="0000000000001d601e05cdf83ae8" X-Rspamd-Queue-Id: 4HRq5J5QKnz4XJy X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: Y --0000000000001d601e05cdf83ae8 Content-Type: text/plain; charset="UTF-8" On Sat, Oct 9, 2021 at 10:06 PM Baptiste Daroussin wrote: > On Sun, Oct 10, 2021 at 02:52:58AM +0300, Konstantin Belousov wrote: > > On Sat, Oct 09, 2021 at 05:29:39PM -0600, Warner Losh wrote: > > > On Sat, Oct 9, 2021, 5:15 PM Konstantin Belousov > > > wrote: > > > > > > > On Sat, Oct 09, 2021 at 04:47:35PM -0600, Warner Losh wrote: > > > > > On Sat, Oct 9, 2021 at 11:09 AM Dimitry Andric > wrote: > > > > > > > > > > > On 9 Oct 2021, at 15:40, Warner Losh wrote: > > > > > > > > > > > > > > On Sat, Oct 9, 2021, 5:59 AM Dimitry Andric > wrote: > > > > > > > On 9 Oct 2021, at 13:37, Dimitry Andric > wrote: > > > > > > > > > > > > > > > > On 9 Oct 2021, at 09:46, FreeBSD User < > freebsd@walstatt-de.de> > > > > wrote: > > > > > > > >> > > > > > > > >> On recent CURRENT (FreeBSD 14.0-CURRENT #2 > > > > main-n249971-0525ece3554e: > > > > > > > >> Fri Oct 8 15:17:34 CEST 2021 amd64) building of an > 13-STABLE > > > > based > > > > > > > >> appliance failed very early in the build process of the > 13-STABLE > > > > > > > >> sources as shown below. 13-STABLE is most recent, since the > > > > sources > > > > > > are > > > > > > > >> fetched every time the build process is triggered. > > > > > > > > ... > > > > > > > >> > > > > > > > /pool/home/ohartmann/Projects/router/router/apu2c4/src/tools/install.sh > > > > > > > >> -s -o root -g wheel -m 555 compile_et > > > > > > > >> /pool/home/ohartmann/Projects/router/router/apu2 > > > > > > > >> > > > > > > > > > > > c4/world/amd64/ALERICH_13-STABLE_amd64/pool/home/ohartmann/Projects/router/router/apu2c4/src/amd64.amd64/tmp/legacy/usr/bin/compile_et > > > > > > > >> --- _bootstrap-tools-usr.bin/clang/llvm-tblgen --- ld: > error: > > > > > > undefined > > > > > > > >> symbol: setupterm > > > > > > > >>>>> referenced by Process.cpp > > > > > > > >>>>> > > > > > > Process.o:(llvm::sys::Process::FileDescriptorHasColors(int)) > > > > > > > > > > > > > > > > It is complaining about ncurses functions; it seems that even > > > > though > > > > > > the link step gets -lncursesw added, it still is not able to > find the > > > > > > symbol: > > > > > > > > > > > > > > Okay, this is because recently on -CURRENT, libtinfow got > split off > > > > from > > > > > > > libncursesw: > https://cgit.freebsd.org/src/commit/?id=396851c20aebd > > > > > > > > > > > > > > This affects such cross-builds obviously, and manually adding > > > > -ltinfow > > > > > > > to the link command line makes it link correctly. > > > > > > > > > > > > > > However, the 396851c20aebd commit is probably not suitable for > > > > MFC'ing > > > > > > > to stable/13. Maybe we need to put some kind of kludge in > > > > > > > share/mk/src.libnames.mk for this, or in the top-level > > > > Makefile.inc1? > > > > > > > > > > > > > > Baptiste, any ideas? :) > > > > > > > > > > > > > > Add setupterm() to libegacy as a nop. > > > > > > > > > > > > That's not enough I think, it requires more ncurses functions > than just > > > > > > setupterm. And it actually calls them and checks the return > values too, > > > > > > IIRC. :) > > > > > > > > > > > > > > > > int setupterm(const char *t, int fd, int *errptr) { return OK; } > > > > > int tigetnum(const char *t) { return 0; } > > > > > TERMINAL *set_curterm(TERMINAL *t) { return NULL; } > > > > > int del_curterm(TERMINAL *t) { return OK; } > > > > > > > > > > should do the trick. I'll see just how crazy an idea this might be > > > > > since we're trying to get the first stage tool to work on a > -current > > > > > host. the only thing that clang is really using is tigetnum to see > > > > > if the terminal has color. Returning 0 tells it no. > > > > > > > > > > Or we could contrive, during bootstrap, to ensure that > > > > > LLVM_ENABLE_TERMINFO is not defined. Nobody ever needs > > > > > color error messages. They are nice to have, sure, but are not > > > > > strictly needed if the alternative is monochrome error messages > > > > > while building the system. There's already an ifdef protecting it: > > > > > > > > > > /* Define if the setupterm() function is supported this platform. > */ > > > > > #if defined(__FreeBSD__) > > > > > /* > > > > > * This is only needed for terminalHasColors(). When disabled LLVM > falls > > > > > back > > > > > * to checking a list of TERM prefixes which is sufficient for a > > > > bootstrap > > > > > tool. > > > > > */ > > > > > #define LLVM_ENABLE_TERMINFO 1 > > > > > #endif > > > > > > > > > > It would be easy enough to add a && !defined(LLVM_BOOTSTRAP_BUILD) > > > > > or similar. > > > > > > > > I do not quite understand how would it help. > > > > You need to add this to HEAD sources back in time, not to the current > > > > sources. > > > > > > > > > > Once merged, this would get stable building on current. But not older > > > versions of stable, it is true. It's worth doing for that reason alone > > > unless there's something clever we've not thought of yet with the > current > > > host. > > > > We can put somewhere a patch and add instructions how to use it to patch > > older HEADs and stable. May be instructions and the reference to the > patch > > file should go into UPDATING 20211004 entry. > > It fails to link because the bootstrap tools are built statically if they > were > linked dynamically that would solve the situation, because libncursesw.so > is a > linkscript which does the right thing. > > Stupid question, why are bootstrap tools statically linked in the first > place? > If we remove -DNO_SHARED from the BARGS, it compiles perfectly fine. > I support this. It's a lot better than my idea. I did a deep dive with 'git blame' and after a look way back in time, this was added back when miniperl was added to the cross tools as a "while I'm here" change stop building the bootstrap shared and profile binaries (so it was an optimization). This will increase the build time a bit since we build libraries twice now (both static and shared). But we don't normally build libraries when bootstrapping, though. Back when this change was done, we built a lot during the bootstrapping. But that's no longer the case. 12 -> 13 (or current) will build a couple of libraries, so if they are built both shared and static the added time will be, at best, negligible. From older upgrades, more is built, but newer clang versions likely make it impossible to upgrade from such versions (likely time to GC them... I'll take a look at doing that). Warner P.S. Here's where it was added: commit ad879ce9552cb94f4709c6e41a31a060d1c9c335 Author: Marcel Moolenaar Date: Mon Nov 20 02:17:34 2000 +0000 Fix cross-building. o Move building libperl and miniperl from build-tools to cross-tools. libperl uses MACHINE_ARCH to determine the right configuration, which doesn't match the build machine when cross-building if they are built as build- tools. o Since miniperl needs to be built as a cross-tool, it needs to be installed under /usr/obj so that it can be used (cross-tools have a special object directory to avoid build conflicts. As a downside, you can't easily run cross-tools from their object directory). Remove the install and distribute override targets. To avoid having miniperl installed by installworld, remove it from SUBDIR. o We can't pickup miniperl from the object directory but since it's installed, depend on PATH. This is save, because the makefiles are run with a known path. o Build libperl again as part of the library target. A _libperl variable existed, but it was never defined. o Add chmod to the list of saved tools, because perl conditionally uses it during install. The bootstrap-tools and cross-tools targets are modified to avoid building profiled and shared libraries. While here, have these targets build static binaries instead of shared binaries. Approved by: markm Notes: svn path=/head/; revision=68927 > Imho we should remove the static linking here, the other way would be to > provide a "flat" libncursesw.a for those cases on CURRENT. which I don't > know how to > provide without breaking things even more. > > Best regards, > Bapt > --0000000000001d601e05cdf83ae8--