diff --git a/specs/binary_install.anod b/specs/binary_install.anod index 627cd199..7c37176a 100644 --- a/specs/binary_install.anod +++ b/specs/binary_install.anod @@ -11,11 +11,11 @@ class binary_install(spec("common")): @property def tarball(self): raise NotImplementedError - + @property def url(self): raise NotImplementedError - + @property def remove_root_dir(self): return True diff --git a/specs/gnatcov.anod b/specs/gnatcov.anod index aaeb7c08..078f30d8 100644 --- a/specs/gnatcov.anod +++ b/specs/gnatcov.anod @@ -3,7 +3,6 @@ from e3.fs import cp from e3.anod.helper import Make from e3.anod.spec import Anod from e3.anod.loader import spec -from e3.diff import patch import os @@ -13,7 +12,7 @@ patch_name = "gnatcov.patch" class GNATcov(spec("common")): @property def version(self): - return "22.0" + return "26.0" @property def tarball(self): @@ -34,7 +33,6 @@ class GNATcov(spec("common")): def build_source_list(self): return [ Anod.Source(name=self.tarball, publish=True, dest=""), - self.Source(name=patch_name, publish=True, unpack_cmd=cp, dest="patches"), ] @property @@ -45,13 +43,14 @@ class GNATcov(spec("common")): Anod.Dependency("libgpr", track=True), Anod.Dependency("gnatcoll", track=True), Anod.Dependency("gnatcoll-bindings", track=True), - Anod.Dependency("langkit", track=True), + Anod.Dependency("langkit_support", track=True), Anod.Dependency("libadalang", track=True), Anod.Dependency("binutils", track=True), Anod.Dependency("gnatutil", track=True), Anod.Dependency("xmlada", track=True), Anod.Dependency("zlib", track=True), - Anod.Dependency("gmp", track=True) + Anod.Dependency("gmp", track=True), + Anod.Dependency("llvm", track=True), ] if self.env.target.os.name == "windows": deps.append(Anod.Dependency("libiconv")) @@ -63,16 +62,6 @@ class GNATcov(spec("common")): for m in [d for d in self.deps if d != "binutils"]: self.deps[m].setenv() - # Little hack to apply the patch only once, there is probably a clean - # way to do that. - patched = os.path.join(self["SRC_DIR"], "patches", ".patched") - if not os.path.exists(patched): - patch( - os.path.join(self["SRC_DIR"], "patches", patch_name), - self.build_space.src_dir, - ) - touch(patched) - build_mode = "prod" exec_dir = os.path.join(self["SRC_DIR"], "tools", "gnatcov") @@ -80,6 +69,7 @@ class GNATcov(spec("common")): make_all.set_default_target("all") make_all.set_var("BINUTILS_SRC_DIR", self.deps["binutils"]["SRC_DIR"]) make_all.set_var("BINUTILS_BUILD_DIR", self.deps["binutils"]["BUILD_DIR"]) + make_all.set_var("C_SUPPORT", "False") make_distrib = Make(self, exec_dir=exec_dir) make_distrib.set_var("PREFIX", unixpath(self["INSTALL_DIR"])) @@ -89,8 +79,21 @@ class GNATcov(spec("common")): m.set_var("BITS_ARCH", str(self.env.target.cpu.bits)) m.set_var("DISTRIB_ARCH", self.env.build.cpu.name) m.set_var("BUILD_MODE", build_mode) - m.set_var("ADAPTERS_LIST", "") + m.set_var("ADAPTERS_LIST", "llvm_json") make_all() make_distrib() + + cp( + source=os.path.join( + self.deps["llvm"]["INSTALL_DIR"], + "bin", + "llvm-profdata" + self.env.build.os.exeext, + ), + target=os.path.join( + self["PKG_DIR"], + "libexec", + "gnatcoverage", + ), + ) self.clean() diff --git a/specs/gnatutil.anod b/specs/gnatutil.anod index e24f5522..6c7e7e24 100644 --- a/specs/gnatutil.anod +++ b/specs/gnatutil.anod @@ -8,7 +8,7 @@ import os class GNATUTIL(spec("common")): @property def version(self): - return "20.0w-20190814-1532A" + return "26.0w-20250825" @property def tarball(self): diff --git a/specs/llvm.anod b/specs/llvm.anod new file mode 100644 index 00000000..36d89e63 --- /dev/null +++ b/specs/llvm.anod @@ -0,0 +1,40 @@ +from e3.anod.loader import spec +from e3.fs import sync_tree +from e3.anod.spec import Anod +import os + +class LLVM(spec("binary_install")): + @property + def version(self): + return "20.1.8" + + @property + def platform(self): + if self.env.host.os.name == "windows": + return "x86_64-pc-windows-msvc" + if self.env.host.os.name == "darwin": + if self.env.host.cpu.name == "arm": + return "macos-arm64" + else: + # Unsupported + raise NotImplementedError + else: + if self.env.host.cpu.name == "x86_64": + return "linux-x64" + else: + return "linux-arm64" + + @property + def tool(self): + if self.env.host.os.name == "windows": + return "clang+llvm" + else: + return "LLVM" + + @property + def tarball(self): + return f"{self.tool}-{self.version}-{self.platform}.tar.xz" + + @property + def url(self): + return f"https://github.com/llvm/llvm-project/releases/download/llvmorg-{self.version}/{self.tarball}" diff --git a/specs/patches/gnat_util-20.0w-20190814-1532A-src.tar.gz b/specs/patches/gnat_util-20.0w-20190814-1532A-src.tar.gz deleted file mode 100644 index fb7e843d..00000000 Binary files a/specs/patches/gnat_util-20.0w-20190814-1532A-src.tar.gz and /dev/null differ diff --git a/specs/patches/gnat_util-26.0w-20250825-src.tar.gz b/specs/patches/gnat_util-26.0w-20250825-src.tar.gz new file mode 100644 index 00000000..e1feff2b Binary files /dev/null and b/specs/patches/gnat_util-26.0w-20250825-src.tar.gz differ diff --git a/specs/patches/gnatcov.patch b/specs/patches/gnatcov.patch deleted file mode 100644 index c8a7587f..00000000 --- a/specs/patches/gnatcov.patch +++ /dev/null @@ -1,503 +0,0 @@ -diff --git tools/gnatcov/Makefile tools/gnatcov/Makefile -index 1c157cd88..d0d63bc69 100644 ---- tools/gnatcov/Makefile -+++ tools/gnatcov/Makefile -@@ -82,7 +82,7 @@ PGM64PATH=obj64/$(BUILD_MODE)/gnatcov64 - DIRNAME=gnatcoverage - - include host.mk --include common.mk -+# include common.mk - - ##################################################################### - # Targets to build the core tool and the trace adapters, optionally # -@@ -299,7 +299,7 @@ install-adapters: $(INSTALL_ADAPTER_TARGETS) - # which has its own extra info embedded and eventually installs just all what - # the distrib tree contains. We don't want any toplevel item there. - --.PHONY: distrib-linux-extra distrib-windows-extra distrib -+.PHONY: distrib-linux-extra distrib-windows-extra distrib-darwin-extra distrib - - distrib-linux-extra: - [ -f COPYING3 ] || $(CP) ../../COPYING3 . -@@ -311,6 +311,8 @@ distrib-linux-extra: - - distrib-windows-extra: - -+distrib-darwin-extra: -+ - distrib-common: install-adapters distrib-${HOST_OS}-extra - distrib-without-doc: distrib-common install-without-doc - distrib: distrib-without-doc -diff --git tools/gnatcov/clang-wrapper.cc tools/gnatcov/clang-wrapper.cc -deleted file mode 100644 -index a8b8493a0..000000000 ---- tools/gnatcov/clang-wrapper.cc -+++ /dev/null -@@ -1,369 +0,0 @@ --/**************************************************************************** -- * * -- * GNATcoverage * -- * * -- * Copyright (C) 2021, AdaCore * -- * * -- * GNATcoverage is free software; you can redistribute it and/or modify it * -- * under terms of the GNU General Public License as published by the Free * -- * Software Foundation; either version 3, or (at your option) any later * -- * version. This software is distributed in the hope that it will be useful * -- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * -- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * -- * License for more details. You should have received a copy of the GNU * -- * General Public License distributed with this software; see file * -- * COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy * -- * of the license. * -- * * -- ****************************************************************************/ -- --/* Make sure we refer to the static version of symbols on Windows, not to DLL -- importers. */ -- --#define CINDEX_NO_EXPORTS -- --#include "libclang/CXCursor.h" --#include "libclang/CXSourceLocation.h" --#include "libclang/CXString.h" --#include "libclang/CXTranslationUnit.h" --#include "libclang/CursorVisitor.h" --#include "clang-c/Index.h" --#include "clang-c/Rewrite.h" --#include "clang/AST/ASTContext.h" --#include "clang/AST/ParentMapContext.h" --#include "clang/Frontend/ASTUnit.h" --#include "clang/Lex/Lexer.h" --#include "clang/Lex/Token.h" --#include "clang/Rewrite/Core/Rewriter.h" -- --using namespace clang; --using namespace clang::cxcursor; --using namespace clang::cxloc; --using namespace clang::cxstring; --using namespace clang::cxtu; -- --/* Convert a clang Stmt type to a libclang CXCursor structure. The CXCursor C -- is simply used to get a relevant declaration and translation unit to tie -- the returned cursor to. */ -- --CXCursor --MakeCXCursorWithNull (const Stmt *S, CXCursor C) --{ -- if (S) -- return MakeCXCursor (S, getCursorDecl (C), getCursorTU (C)); -- else -- return clang_getNullCursor (); --} -- --/* Most of the functions are getters around existing clang functions of a -- similar name, for the accepted type(s). For instance, clang_getCond will -- simply call getCond on the given node, if this is a statement or an -- expression that has this getter (an IfStmt, WhileStmt etc.). Some checks -- are done, to make sure this is a supported type, before actually calling the -- wrapped function on the casted node. */ -- --extern "C" CXCursor --clang_getCond (CXCursor C) --{ -- if (clang_isStatement (C.kind) || clang_isExpression (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::IfStmtClass: -- return MakeCXCursorWithNull (cast (S)->getCond (), C); -- case Stmt::WhileStmtClass: -- return MakeCXCursorWithNull (cast (S)->getCond (), C); -- case Stmt::ForStmtClass: -- return MakeCXCursorWithNull (cast (S)->getCond (), C); -- case Stmt::SwitchStmtClass: -- return MakeCXCursorWithNull (cast (S)->getCond (), C); -- case Stmt::DoStmtClass: -- return MakeCXCursorWithNull (cast (S)->getCond (), C); -- case Stmt::ConditionalOperatorClass: -- return MakeCXCursorWithNull ( -- cast (S)->getCond (), C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getBody (CXCursor C) --{ -- if (clang_isDeclaration (C.kind)) -- { -- if (const Decl *D = cxcursor::getCursorDecl (C)) -- return MakeCXCursorWithNull (D->getBody (), C); -- } -- else if (clang_isStatement (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::WhileStmtClass: -- return MakeCXCursorWithNull (cast (S)->getBody (), C); -- case Stmt::ForStmtClass: -- return MakeCXCursorWithNull (cast (S)->getBody (), C); -- case Stmt::DoStmtClass: -- return MakeCXCursorWithNull (cast (S)->getBody (), C); -- case Stmt::SwitchStmtClass: -- return MakeCXCursorWithNull (cast (S)->getBody (), C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getForInit (CXCursor C) --{ -- if (clang_isStatement (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::ForStmtClass: -- return MakeCXCursorWithNull (cast (S)->getInit (), C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getForInc (CXCursor C) --{ -- if (clang_isStatement (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::ForStmtClass: -- return MakeCXCursorWithNull (cast (S)->getInc (), C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getThen (CXCursor C) --{ -- if (clang_isStatement (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::IfStmtClass: -- return MakeCXCursorWithNull (cast (S)->getThen (), C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getElse (CXCursor C) --{ -- if (clang_isStatement (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::IfStmtClass: -- return MakeCXCursorWithNull (cast (S)->getElse (), C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getSubExpr (CXCursor C) --{ -- if (clang_isExpression (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::UnaryOperatorClass: -- return MakeCXCursorWithNull (cast (S)->getSubExpr (), -- C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getSubStmt (CXCursor C) --{ -- if (clang_isStatement (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::CaseStmtClass: -- return MakeCXCursorWithNull (cast (S)->getSubStmt (), C); -- case Stmt::DefaultStmtClass: -- return MakeCXCursorWithNull (cast (S)->getSubStmt (), -- C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getRHS (CXCursor C) --{ -- if (clang_isExpression (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::BinaryOperatorClass: -- return MakeCXCursorWithNull (cast (S)->getRHS (), C); -- case Stmt::ConditionalOperatorClass: -- return MakeCXCursorWithNull ( -- cast (S)->getRHS (), C); -- } -- return clang_getNullCursor (); --} -- --extern "C" CXCursor --clang_getLHS (CXCursor C) --{ -- if (clang_isExpression (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullCursor (); -- case Stmt::BinaryOperatorClass: -- return MakeCXCursorWithNull (cast (S)->getLHS (), C); -- case Stmt::ConditionalOperatorClass: -- return MakeCXCursorWithNull ( -- cast (S)->getRHS (), C); -- } -- return clang_getNullCursor (); --} -- --/* Return the string representative of the operator for a binary or unary -- operator node. */ -- --extern "C" CXString --clang_getOpcodeStr (CXCursor C) --{ -- if (clang_isExpression (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return createEmpty (); -- case Stmt::BinaryOperatorClass: -- return createRef (BinaryOperator::getOpcodeStr ( -- cast (S)->getOpcode ())); -- case Stmt::UnaryOperatorClass: -- return createRef (UnaryOperator::getOpcodeStr ( -- cast (S)->getOpcode ())); -- } -- return createEmpty (); --} -- --/* Return the location of the operator for a binary / unary operator node. */ -- --extern "C" CXSourceLocation --clang_getOperatorLoc (CXCursor C) --{ -- ASTUnit *CXXUnit = cxtu::getASTUnit (getCursorTU (C)); -- if (!CXXUnit) -- return clang_getNullLocation (); -- SourceLocation sloc; -- if (clang_isExpression (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- switch (S->getStmtClass ()) -- { -- default: -- return clang_getNullLocation (); -- case Stmt::BinaryOperatorClass: -- sloc = cast (S)->getOperatorLoc (); -- break; -- case Stmt::UnaryOperatorClass: -- sloc = cast (S)->getOperatorLoc (); -- break; -- } -- return cxloc::translateSourceLocation (CXXUnit->getASTContext (), sloc); --} -- --/* If the given expression is a paren expression, return the outermost -- expression inside that is not a paren expression. */ -- --extern "C" CXCursor --clang_unwrap (CXCursor C) --{ -- if (clang_isExpression (C.kind)) -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- if (S->getStmtClass () == Stmt::ParenExprClass) -- return clang_unwrap ( -- MakeCXCursorWithNull (cast (S)->getSubExpr (), C)); -- return C; --} -- --/* Visit a node, starting by itself (in contrary to clang_visitChildren that -- immediately starts with the children of the node). */ -- --extern "C" unsigned --clang_visit (CXCursor parent, CXCursorVisitor visitor, -- CXClientData client_data) --{ -- cxcursor::CursorVisitor CursorVis (getCursorTU (parent), visitor, -- client_data, -- /*VisitPreprocessorLast=*/false); -- return CursorVis.Visit (parent); --} -- --/* Returns the parent node of the given node. This accepts statements and -- expressions, unlike clang_getLexicalParent and clang_getCursorParent. */ -- --extern "C" CXCursor --clang_getParent (CXCursor C) --{ -- assert (clang_isStatement (C.kind) || clang_isExpression (C.kind)); -- ASTUnit *astUnit = cxtu::getASTUnit (getCursorTU (C)); -- ASTContext &astContext = astUnit->getASTContext (); -- if (const Stmt *S = cxcursor::getCursorStmt (C)) -- { -- const auto Parents = astContext.getParents (*S); -- if (Parents.empty ()) -- return clang_getNullCursor (); -- const auto &SParent = Parents[0]; -- if (const auto *Res = SParent.get ()) -- return MakeCXCursorWithNull (Res, C); -- } -- return clang_getNullCursor (); --} -- --/* Wrappers around rewriting functions. */ -- --extern "C" void --clang_CXRewriter_insertTextAfter (CXRewriter Rew, CXSourceLocation Loc, -- const char *Insert) --{ -- assert (Rew); -- clang::Rewriter &R = *reinterpret_cast (Rew); -- R.InsertTextAfter (clang::cxloc::translateSourceLocation (Loc), Insert); --} -- --extern "C" void --clang_CXRewriter_insertTextAfterToken (CXRewriter Rew, CXSourceLocation Loc, -- const char *Insert) --{ -- assert (Rew); -- clang::Rewriter &R = *reinterpret_cast (Rew); -- R.InsertTextAfterToken (clang::cxloc::translateSourceLocation (Loc), Insert); --} -- --extern "C" unsigned --clang_CXRewriter_isRewritable (CXSourceLocation Loc) --{ -- return clang::Rewriter::isRewritable ( -- clang::cxloc::translateSourceLocation (Loc)) -- ? 1 -- : 0; --} -diff --git tools/gnatcov/gnatcov.gpr tools/gnatcov/gnatcov.gpr -index 361faeac9..7074a4dd8 100644 ---- tools/gnatcov/gnatcov.gpr -+++ tools/gnatcov/gnatcov.gpr -@@ -1,4 +1,4 @@ --with "gnat_util", "gnatcoll", "libadalang", "libclang"; -+with "gnat_util", "gnatcoll", "libadalang"; - - with "rts/gnatcov_rts"; - -diff --git tools/gnatcov/host.mk tools/gnatcov/host.mk -index 53ba4b0be..445095784 100644 ---- tools/gnatcov/host.mk -+++ tools/gnatcov/host.mk -@@ -14,6 +14,11 @@ HOST_OS=linux - LN_S=ln -sf - exeext= - endif -+ifneq (,$(filter Darwin, $(HOST_UNAME))) -+HOST_OS=darwin -+LN_S=ln -sf -+exeext= -+endif - - RM=rm -f - CP=cp -pf -diff --git tools/gnatcov/instrument.adb tools/gnatcov/instrument.adb -index 25dbe924f..cd3dcfdd4 100644 ---- tools/gnatcov/instrument.adb -+++ tools/gnatcov/instrument.adb -@@ -46,7 +46,6 @@ with GNATcov_RTS.Buffers; use GNATcov_RTS.Buffers; - with Instrument.Ada_Unit; - with Instrument.Base_Types; use Instrument.Base_Types; - with Instrument.Clean_Objdirs; --with Instrument.C; - with Instrument.Common; use Instrument.Common; - with Instrument.Find_Ada_Units; - with Outputs; use Outputs; -@@ -362,21 +361,22 @@ package body Instrument is - Mains : Main_To_Instrument_Vectors.Vector) - is - begin -- for Main of Mains loop -- declare -- use type GNATCOLL.VFS.Filesystem_String; -- Rewriter : Instrument.C.C_Source_Rewriter; -- begin -- Rewriter.Start_Rewriting -- (IC, Main.Prj_Info.all, +Main.File.Full_Name); -- Instrument.C.Add_Auto_Dump_Buffers -- (IC => IC, -- Info => Main.Prj_Info.all, -- Main => Main.CU_Name, -- Rew => Rewriter); -- Rewriter.Apply; -- end; -- end loop; -+ null; -+ -- for Main of Mains loop -+ -- declare -+ -- use type GNATCOLL.VFS.Filesystem_String; -+ -- Rewriter : Instrument.C.C_Source_Rewriter; -+ -- begin -+ -- Rewriter.Start_Rewriting -+ -- (IC, Main.Prj_Info.all, +Main.File.Full_Name); -+ -- Instrument.C.Add_Auto_Dump_Buffers -+ -- (IC => IC, -+ -- Info => Main.Prj_Info.all, -+ -- Main => Main.CU_Name, -+ -- Rew => Rewriter); -+ -- Rewriter.Apply; -+ -- end; -+ -- end loop; - end Auto_Dump_Buffers_In_C_Mains; - - ---------------------------------- -@@ -608,8 +608,9 @@ package body Instrument is - (CU.Name, IC, Unit_Info); - - when C_Language => -- Instrument.C.Instrument_Unit -- (CU.Name, IC, Unit_Info); -+ null; -+ -- Instrument.C.Instrument_Unit -+ -- (CU.Name, IC, Unit_Info); - end case; - - -- Update the Ignore_Status of the CU we instrumented -@@ -694,7 +695,7 @@ package body Instrument is - -- that are units of interest. - - Auto_Dump_Buffers_In_Ada_Mains (IC, Ada_Main_To_Instrument_Vector); -- Auto_Dump_Buffers_In_C_Mains (IC, C_Main_To_Instrument_Vector); -+ -- Auto_Dump_Buffers_In_C_Mains (IC, C_Main_To_Instrument_Vector); - - -- Remove sources in IC.Output_Dir that we did not generate this time. - -- They are probably left overs from previous instrumentations for units