NetBSD Problem Report #55290
From www@netbsd.org Sat May 23 12:27:03 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 741251A9244
for <gnats-bugs@gnats.NetBSD.org>; Sat, 23 May 2020 12:27:03 +0000 (UTC)
Message-Id: <20200523122702.192B91A9245@mollari.NetBSD.org>
Date: Sat, 23 May 2020 12:27:02 +0000 (UTC)
From: romain@dolbeau.org
Reply-To: romain@dolbeau.org
To: gnats-bugs@NetBSD.org
Subject: 'llvm' fail to cross-compile (it uses target's llvm-tblgen)
X-Send-Pr-Version: www-1.0
>Number: 55290
>Category: pkg
>Synopsis: 'llvm' fail to cross-compile (it uses target's llvm-tblgen)
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 23 12:30:00 +0000 2020
>Last-Modified: Mon May 25 08:15:01 +0000 2020
>Originator: Romain Dolbeau
>Release: pkgsrc 2020Q1
>Organization:
-
>Environment:
NetBSD amd64-netbsd 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
When trying to cross-compile from NetBSD 9.0/amd64 to NetBSD 9.0/sparc, llvm fails to cross-compile as it cannot execute the "../../bin/llvm-tblgen" binary - which of course is a sparc binary. It seems the required cmake parameters are missing.
>How-To-Repeat:
cross-compile llvm from NetBSD 9.0/amd64 to NetBSD 9.0/sparc. Please note that this requires some sparc packages that have been compiled natively as they won't cross-compile (e.g. python37).
>Fix:
I forced the cross-compilation options to cmake in the package Makefile:
#####
diff -u -r1.51 Makefile
--- Makefile 22 Mar 2020 18:01:21 -0000 1.51
+++ Makefile 23 May 2020 12:21:57 -0000
@@ -51,6 +51,10 @@
CMAKE_ARGS+= -DLLVM_LINK_LLVM_DYLIB=ON
CMAKE_ARGS+= -DLLVM_ENABLE_RTTI=ON
+CMAKE_ARGS+= -DCMAKE_CROSSCOMPILING=True
+CMAKE_ARGS+= -DLLVM_TABLEGEN=/usr/pkg/bin/llvm-tblgen
+CMAKE_ARGS+= -DCLANG_TABLEGEN=/usr/pkg/bin/clang-tblgen
+
CMAKE_ARGS.Darwin+= -DCMAKE_LIBTOOL=/usr/bin/libtool
CHECK_PORTABILITY_SKIP= utils/buildit/build_llvm
#####
I don't know how to 1) properly detect this is a cross-compilation and 2) require the llvm package to be installed for the native llvm-tblgen (clang-tblgen is probably not needed for llvm, only for clang), so this is not a 'proper' fix.
>Audit-Trail:
From: Romain Dolbeau <romain@dolbeau.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/55290: 'llvm' fail to cross-compile (it uses target's llvm-tblgen)
Date: Mon, 25 May 2020 10:13:33 +0200
Extra note; the resulting LLVM default to a x86-64 target (despite it
not being built), I had to also add this:
CMAKE_ARGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=sparc--netbsdelf
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.