Skip to content

Commit

Permalink
Split up patches
Browse files Browse the repository at this point in the history
  • Loading branch information
IsabelParedes authored and h-vetinari committed Aug 9, 2024
1 parent 4d03da8 commit e1f7fe2
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 205 deletions.
9 changes: 8 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ source:
- patches/0001-Instructions-for-building-a-functional-Flang-cross-c.patch
- patches/0002-Minimal-WASM-support-for-flang.patch
- patches/0003-Specialize-Flang-to-target-WASM.patch
- patches/0004-Patches-to-build-flang-runtime-with-emcc.patch
# see https://github.com/llvm/llvm-project/pull/99465
- patches/0004-Fix-implicit-conversion-warning-when-targeting-32bit.patch
# see https://github.com/llvm/llvm-project/pull/99822
- patches/0005-Explicitly-convert-shift-value-to-SubscriptValue.patch
# see https://github.com/llvm/llvm-project/pull/101242
- patches/0006-Handle-missing-definitions-in-cfenv.patch
- patches/0007-Patches-to-build-flang-runtime-with-emcc.patch

build:
number: 0
# intentionally only windows (main target) & linux (debuggability)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From a19d27703e5767348bc890c52ecc1a31ada13f4d Mon Sep 17 00:00:00 2001
From b52f5ea131d3b4280797c3e771f3cbee1960b81b Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@mozilla.com>
Date: Fri, 5 Jul 2024 22:45:47 +0200
Subject: [PATCH 1/4] Instructions for building a functional Flang cross
Subject: [PATCH 1/7] Instructions for building a functional Flang cross
compiler

---
Expand Down
6 changes: 3 additions & 3 deletions recipe/patches/0002-Minimal-WASM-support-for-flang.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From e6bd169ba2c3065712005ae510fe45d2794b7072 Mon Sep 17 00:00:00 2001
From 582eb2b0305e7979a73c9d8aff8bc6917dd9f6a2 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@mozilla.com>
Date: Tue, 18 Jun 2024 22:19:09 +0200
Subject: [PATCH 2/4] Minimal WASM support for flang
Subject: [PATCH 2/7] Minimal WASM support for flang

Original patch from https://gws.phd/posts/fortran_wasm/
---
flang/lib/Optimizer/CodeGen/Target.cpp | 41 ++++++++++++++++++++++++++
1 file changed, 41 insertions(+)

diff --git a/flang/lib/Optimizer/CodeGen/Target.cpp b/flang/lib/Optimizer/CodeGen/Target.cpp
index 25141102a8c4..715daefc0ba5 100644
index 652e2bddc1b8..d7c369616e85 100644
--- a/flang/lib/Optimizer/CodeGen/Target.cpp
+++ b/flang/lib/Optimizer/CodeGen/Target.cpp
@@ -1055,6 +1055,44 @@ struct TargetLoongArch64 : public GenericTarget<TargetLoongArch64> {
Expand Down
12 changes: 6 additions & 6 deletions recipe/patches/0003-Specialize-Flang-to-target-WASM.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
From 2f67a50556da2d1cb8b75640da9ff2e058fe33b5 Mon Sep 17 00:00:00 2001
From d123cb38217b717730c8c09a8dda4b8c59e7e990 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@mozilla.com>
Date: Wed, 10 Jul 2024 22:42:19 +0200
Subject: [PATCH 3/4] Specialize Flang to target WASM
Subject: [PATCH 3/7] Specialize Flang to target WASM

Many values were explicitly encoded under the assumation that host and target have
Many values were explicitly encoded under the assumption that host and target have
the same architecture.
---
.../Optimizer/Builder/Runtime/RTBuilder.h | 31 ++++++++++---------
Expand Down Expand Up @@ -178,10 +178,10 @@ index d21576bb95f7..5372039d8702 100644
/// Create an mlir::DataLayoutSpecInterface attribute from an llvm::DataLayout
/// and set it on the provided mlir::ModuleOp.
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index f9ea92a843b2..ca72d67400b0 100644
index 7483acfcd1ca..211256a1d286 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -909,7 +909,8 @@ getMalloc(fir::AllocMemOp op, mlir::ConversionPatternRewriter &rewriter) {
@@ -910,7 +910,8 @@ getMalloc(fir::AllocMemOp op, mlir::ConversionPatternRewriter &rewriter) {
return mlir::SymbolRefAttr::get(userMalloc);
mlir::OpBuilder moduleBuilder(
op->getParentOfType<mlir::ModuleOp>().getBodyRegion());
Expand All @@ -191,7 +191,7 @@ index f9ea92a843b2..ca72d67400b0 100644
auto mallocDecl = moduleBuilder.create<mlir::LLVM::LLVMFuncOp>(
op.getLoc(), mallocName,
mlir::LLVM::LLVMFunctionType::get(getLlvmPtrType(op.getContext()),
@@ -976,8 +977,11 @@ struct AllocMemOpConversion : public fir::FIROpConversion<fir::AllocMemOp> {
@@ -977,8 +978,11 @@ struct AllocMemOpConversion : public fir::FIROpConversion<fir::AllocMemOp> {
size = rewriter.create<mlir::LLVM::MulOp>(
loc, ity, size, integerCast(loc, rewriter, ity, opnd));
heap->setAttr("callee", getMalloc(heap, rewriter));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 4c2b2fac044fb1b0ad1c3fda3dc5547eda9a22f9 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@mozilla.com>
Date: Fri, 9 Aug 2024 07:51:07 +0200
Subject: [PATCH 4/7] Fix implicit conversion warning when targeting 32bit

See https://github.com/llvm/llvm-project/pull/99465
---
flang/runtime/derived.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/flang/runtime/derived.cpp b/flang/runtime/derived.cpp
index 0d9e033df4e2..659f54fa344b 100644
--- a/flang/runtime/derived.cpp
+++ b/flang/runtime/derived.cpp
@@ -23,10 +23,9 @@ static RT_API_ATTRS void GetComponentExtents(SubscriptValue (&extents)[maxRank],
const typeInfo::Component &comp, const Descriptor &derivedInstance) {
const typeInfo::Value *bounds{comp.bounds()};
for (int dim{0}; dim < comp.rank(); ++dim) {
- SubscriptValue lb{bounds[2 * dim].GetValue(&derivedInstance).value_or(0)};
- SubscriptValue ub{
- bounds[2 * dim + 1].GetValue(&derivedInstance).value_or(0)};
- extents[dim] = ub >= lb ? ub - lb + 1 : 0;
+ auto lb{bounds[2 * dim].GetValue(&derivedInstance).value_or(0)};
+ auto ub{bounds[2 * dim + 1].GetValue(&derivedInstance).value_or(0)};
+ extents[dim] = ub >= lb ? static_cast<SubscriptValue>(ub - lb + 1) : 0;
}
}

193 changes: 0 additions & 193 deletions recipe/patches/0004-Patches-to-build-flang-runtime-with-emcc.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 2b7c94446934e5c473f4577fd78c9a16cb225e31 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton@mozilla.com>
Date: Fri, 9 Aug 2024 07:57:36 +0200
Subject: [PATCH 5/7] Explicitly convert shift value to SubscriptValue

See https://github.com/llvm/llvm-project/pull/99822
---
flang/runtime/transformational.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index cf1e61c0844d..b6b204be4418 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -508,7 +508,8 @@ void RTDEF(CshiftVector)(Descriptor &result, const Descriptor &source,
SubscriptValue lb{sourceDim.LowerBound()};
for (SubscriptValue j{0}; j < extent; ++j) {
SubscriptValue resultAt{1 + j};
- SubscriptValue sourceAt{lb + (j + shift) % extent};
+ SubscriptValue sourceAt{
+ lb + static_cast<SubscriptValue>(j + shift) % extent};
if (sourceAt < lb) {
sourceAt += extent;
}
@@ -619,7 +620,7 @@ void RTDEF(EoshiftVector)(Descriptor &result, const Descriptor &source,
}
SubscriptValue lb{source.GetDimension(0).LowerBound()};
for (SubscriptValue j{1}; j <= extent; ++j) {
- SubscriptValue sourceAt{lb + j - 1 + shift};
+ SubscriptValue sourceAt{lb + j - 1 + static_cast<SubscriptValue>(shift)};
if (sourceAt >= lb && sourceAt < lb + extent) {
CopyElement(result, &j, source, &sourceAt, terminator);
} else if (boundary) {
Loading

0 comments on commit e1f7fe2

Please sign in to comment.