SHA256
1
0
forked from pool/ldc

Accepting request 1198971 from devel:languages:D

OBS-URL: https://build.opensuse.org/request/show/1198971
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ldc?expand=0&rev=24
This commit is contained in:
Ana Guerrero 2024-09-06 15:18:16 +00:00 committed by Git OBS Bridge
commit cf1927cc61
5 changed files with 24 additions and 203 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bfa4aaee74320a1268843c88e229f339b2df0953a4bcb4fced52ebe0dda1cd95
size 8116363

3
ldc-1.39.0-src.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:839bac36f6073318e36f0b163767e03bdbd3f57d99256b97494ac439b59a4562
size 8554301

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Sep 3 13:47:14 UTC 2024 - Guillaume GARDET <guillaume.gardet@opensuse.org>
- Update to 1.39.0:
- Drop upstream patch merge in 1.34.0:
* riscv64-default-target.patch
-------------------------------------------------------------------
Wed Dec 6 10:18:55 UTC 2023 - Andreas Schwab <schwab@suse.de>

View File

@ -1,7 +1,7 @@
#
# spec file for package ldc
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -16,7 +16,7 @@
#
%define so_ver 102
%define so_ver 109
%define lname_jit libldc-jit
%define lname_runtime libdruntime-%{name}
%define lname_phobos libphobos2-%{name}
@ -50,24 +50,16 @@
%bcond_with ldc_tests
# Dynamic compiling is not supported with LLVM >= 12
%if 0%{?suse_version} > 1550 || ( 0%{?is_opensuse} && 0%{?sle_version} > 150400 )
# We force llvm15 on TW
# https://github.com/ldc-developers/ldc/issues/3747
%global jit_support 0
%else
%if %{pkg_vcmp llvm-devel >= 12}
%global jit_support 0
%else
%global jit_support 1
%endif
%endif
# LLVM LTO is too much for 32bit ARM
%ifarch %arm
%ifarch %{arm}
%define _lto_cflags %nil
%endif
Name: ldc
Version: 1.32.2
Version: 1.39.0
Release: 0
Summary: The LLVM D Compiler
License: Artistic-1.0 AND BSD-3-Clause
@ -76,19 +68,17 @@ URL: https://wiki.dlang.org/LDC
Source0: https://github.com/ldc-developers/ldc/releases/download/v%{version}/ldc-%{version}-src.tar.gz
Source1: %{name}-rpmlintrc
Patch0: ldc-1.9.0-fix_arm_build.patch
Patch1: riscv64-default-target.patch
BuildRequires: cmake
BuildRequires: help2man
BuildRequires: libconfig++-devel
BuildRequires: libcurl-devel
BuildRequires: libstdc++-devel
%if 0%{?suse_version} > 1550 || ( 0%{?is_opensuse} && 0%{?sle_version} > 150400 )
# Cannot build with llvm16, so stick with llvm15 for now
BuildRequires: clang15
BuildRequires: llvm15-devel
BuildRequires: llvm-clang >= 15.0
BuildRequires: llvm-devel >= 15.0
%else
BuildRequires: llvm-clang >= 9.0
BuildRequires: llvm-devel >= 9.0
BuildRequires: llvm-clang >= 15.0
BuildRequires: llvm-devel >= 15.0
%endif
BuildRequires: ncurses-devel
BuildRequires: sqlite3-devel
@ -204,8 +194,8 @@ touch no-suse-rules
%cmake \
-DCMAKE_USER_MAKE_RULES_OVERRIDE=./no-suse-rules \
%if 0%{?suse_version} > 1550 || ( 0%{?is_opensuse} && 0%{?sle_version} > 150400 )
-DCMAKE_C_COMPILER="%{_bindir}/clang-15" \
-DCMAKE_CXX_COMPILER="%{_bindir}/clang++-15" \
-DCMAKE_C_COMPILER="%{_bindir}/clang" \
-DCMAKE_CXX_COMPILER="%{_bindir}/clang++" \
%else
-DCMAKE_C_COMPILER="%{_bindir}/clang" \
-DCMAKE_CXX_COMPILER="%{_bindir}/clang++" \
@ -229,8 +219,8 @@ touch no-suse-rules
%cmake \
-DCMAKE_USER_MAKE_RULES_OVERRIDE=./no-suse-rules \
%if 0%{?suse_version} > 1550 || ( 0%{?is_opensuse} && 0%{?sle_version} > 150400 )
-DCMAKE_C_COMPILER="%{_bindir}/clang-15" \
-DCMAKE_CXX_COMPILER="%{_bindir}/clang++-15" \
-DCMAKE_C_COMPILER="%{_bindir}/clang" \
-DCMAKE_CXX_COMPILER="%{_bindir}/clang++" \
%else
-DCMAKE_C_COMPILER="%{_bindir}/clang" \
-DCMAKE_CXX_COMPILER="%{_bindir}/clang++" \
@ -300,7 +290,7 @@ rm -rf %{buildroot}%{_prefix}/lib/debug
%dir %{ldcincludedir}
%{ldcincludedir}/core
%{ldcincludedir}/ldc
%{ldcincludedir}/__builtins.di
%{ldcincludedir}/__importc_builtins.di
%{ldcincludedir}/importc.h
%{ldcincludedir}/object.d

View File

@ -1,176 +0,0 @@
From cb33ca6ddcbd4cbcde04fd987cf1965d70ed4f51 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Sun, 16 Apr 2023 22:28:41 +0200
Subject: [PATCH] Default to rv64gc for hosted riscv64 target
Also select the correct ABI by default matching the enabled features
(double, float or no floating point).
Fixes #4375
---
CHANGELOG.md | 1 +
driver/targetmachine.cpp | 41 ++++++++++++++++++++++++++++++++++-----
driver/targetmachine.h | 5 ++++-
driver/tool.cpp | 6 +++---
tests/driver/riscv_abi4.d | 6 ++++++
tests/driver/riscv_abi5.d | 6 ++++++
6 files changed, 56 insertions(+), 9 deletions(-)
create mode 100644 tests/driver/riscv_abi4.d
create mode 100644 tests/driver/riscv_abi5.d
diff --git a/driver/targetmachine.cpp b/driver/targetmachine.cpp
index 3f16e20813..74f9efbc06 100644
--- a/driver/targetmachine.cpp
+++ b/driver/targetmachine.cpp
@@ -57,7 +57,7 @@ static llvm::cl::opt<bool, true> preserveDwarfLineSection(
llvm::cl::init(false));
#endif
-const char *getABI(const llvm::Triple &triple) {
+const char *getABI(const llvm::Triple &triple, const llvm::SmallVector<llvm::StringRef, 8> &features) {
llvm::StringRef ABIName(opts::mABI);
if (ABIName != "") {
switch (triple.getArch()) {
@@ -111,6 +111,17 @@ const char *getABI(const llvm::Triple &triple) {
ABIName.str().c_str());
}
+ // checks if the features include ±<feature>
+ auto hasFeature = [&features](llvm::StringRef feature) {
+ for (int i = features.size() - 1; i >= 0; i--) {
+ auto f = features[i];
+ if (f.substr(1) == feature) {
+ return f[0] == '+';
+ }
+ }
+ return false;
+ };
+
switch (triple.getArch()) {
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
@@ -120,6 +131,10 @@ const char *getABI(const llvm::Triple &triple) {
case llvm::Triple::ppc64le:
return "elfv2";
case llvm::Triple::riscv64:
+ if (hasFeature("d"))
+ return "lp64d";
+ if (hasFeature("f"))
+ return "lp64f";
return "lp64";
case llvm::Triple::riscv32:
return "ilp32";
@@ -430,9 +445,13 @@ createTargetMachine(const std::string targetTriple, const std::string arch,
// checks if the features include ±<feature>
auto hasFeature = [&features](llvm::StringRef feature) {
- return std::any_of(
- features.begin(), features.end(),
- [feature](llvm::StringRef f) { return f.substr(1) == feature; });
+ for (int i = features.size() - 1; i >= 0; i--) {
+ auto f = features[i];
+ if (f.substr(1) == feature) {
+ return f[0] == '+';
+ }
+ }
+ return false;
};
// cmpxchg16b is not available on old 64bit CPUs. Enable code generation
@@ -441,6 +460,18 @@ createTargetMachine(const std::string targetTriple, const std::string arch,
features.push_back("+cx16");
}
+ // For a hosted RISC-V 64-bit target default to rv64gc if nothing has
+ // been selected
+ if (triple.getArch() == llvm::Triple::riscv64 &&
+ triple.getOS() != llvm::Triple::UnknownOS &&
+ features.empty()) {
+ features.push_back("+m");
+ features.push_back("+a");
+ features.push_back("+f");
+ features.push_back("+d");
+ features.push_back("+c");
+ }
+
// Handle cases where LLVM picks wrong default relocModel
#if LDC_LLVM_VER >= 1600
if (relocModel.has_value()) {}
@@ -478,7 +509,7 @@ createTargetMachine(const std::string targetTriple, const std::string arch,
opts::InitTargetOptionsFromCodeGenFlags(triple);
if (targetOptions.MCOptions.ABIName.empty())
- targetOptions.MCOptions.ABIName = getABI(triple);
+ targetOptions.MCOptions.ABIName = getABI(triple, features);
if (floatABI == FloatABI::Default) {
switch (triple.getArch()) {
diff --git a/driver/targetmachine.h b/driver/targetmachine.h
index 17e664a2bf..66a84cfd82 100644
--- a/driver/targetmachine.h
+++ b/driver/targetmachine.h
@@ -15,6 +15,8 @@
#pragma once
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CodeGen.h"
#include <string>
#include <vector>
@@ -73,4 +75,5 @@ MipsABI::Type getMipsABI();
const llvm::Target *lookupTarget(const std::string &arch, llvm::Triple &triple,
std::string &errorMsg);
-const char *getABI(const llvm::Triple &triple);
+const char *getABI(const llvm::Triple &triple,
+ const llvm::SmallVector<llvm::StringRef, 8> &features);
diff --git a/driver/tool.cpp b/driver/tool.cpp
index 806e365996..cf633499a8 100644
--- a/driver/tool.cpp
+++ b/driver/tool.cpp
@@ -123,14 +123,14 @@ void appendTargetArgsForGcc(std::vector<std::string> &args) {
case Triple::riscv64:
{
- std::string mabi = getABI(triple);
- args.push_back("-mabi=" + mabi);
-
extern llvm::TargetMachine* gTargetMachine;
auto featuresStr = gTargetMachine->getTargetFeatureString();
llvm::SmallVector<llvm::StringRef, 8> features;
featuresStr.split(features, ",", -1, false);
+ std::string mabi = getABI(triple, features);
+ args.push_back("-mabi=" + mabi);
+
// Returns true if 'feature' is enabled and false otherwise. Handles the
// case where the feature is specified multiple times ('+m,-m'), and
// takes the last occurrence.
diff --git a/tests/driver/riscv_abi4.d b/tests/driver/riscv_abi4.d
new file mode 100644
index 0000000000..a5c93bab61
--- /dev/null
+++ b/tests/driver/riscv_abi4.d
@@ -0,0 +1,6 @@
+// REQUIRES: target_RISCV
+
+// RUN: %ldc %s -mtriple=riscv64-unknown-linux --gcc=echo > %t && FileCheck %s < %t
+// CHECK: -mabi=lp64d -march=rv64gc
+
+void main() {}
diff --git a/tests/driver/riscv_abi5.d b/tests/driver/riscv_abi5.d
new file mode 100644
index 0000000000..11cd97c41c
--- /dev/null
+++ b/tests/driver/riscv_abi5.d
@@ -0,0 +1,6 @@
+// REQUIRES: target_RISCV
+
+// RUN: %ldc %s -mtriple=riscv64-unknown-linux -mattr=+m,+a,+f,-d --gcc=echo > %t && FileCheck %s < %t
+// CHECK: -mabi=lp64f -march=rv64imaf_zicsr_zifencei
+
+void main() {}
--
2.43.0