[flang-commits] [flang] 75f81de - [Flang][FlangRT][Runtime] Add RT_OFFLOAD_API_GROUP_BEGIN to missing symbols on AMDGPU (#147612)

via flang-commits flang-commits at lists.llvm.org
Thu Jul 10 04:20:01 PDT 2025


Author: agozillon
Date: 2025-07-10T13:19:58+02:00
New Revision: 75f81ded8f9d558c92d92641bce3cf7ef8e13e9c

URL: https://github.com/llvm/llvm-project/commit/75f81ded8f9d558c92d92641bce3cf7ef8e13e9c
DIFF: https://github.com/llvm/llvm-project/commit/75f81ded8f9d558c92d92641bce3cf7ef8e13e9c.diff

LOG: [Flang][FlangRT][Runtime]  Add RT_OFFLOAD_API_GROUP_BEGIN to missing symbols on AMDGPU (#147612)

After the recent move to work queues, in certain cases when linking in
the fortran runtime built for offload on AMDGPU as required in certain
cases, we'll get missing symbols when linking. This PR tries to address
this issue by encompassing more of the library in
RT_OFFLOAD_API_GROUP_BEGIN, which has the affect of compiling these
functions for AMDGPU, resolving the missing symbols.

This PR should address the following issue:
https://github.com/llvm/llvm-project/issues/145888

Added: 
    

Modified: 
    flang-rt/include/flang-rt/runtime/format.h
    flang-rt/include/flang-rt/runtime/internal-unit.h
    flang-rt/include/flang-rt/runtime/io-stmt.h
    flang-rt/include/flang-rt/runtime/non-tbp-dio.h
    flang-rt/include/flang-rt/runtime/work-queue.h
    flang-rt/lib/runtime/edit-input.h
    flang-rt/lib/runtime/edit-output.h
    flang-rt/lib/runtime/unit.h
    flang/include/flang/Decimal/decimal.h

Removed: 
    


################################################################################
diff  --git a/flang-rt/include/flang-rt/runtime/format.h b/flang-rt/include/flang-rt/runtime/format.h
index b169d63fa4999..9469cb0ee9a4c 100644
--- a/flang-rt/include/flang-rt/runtime/format.h
+++ b/flang-rt/include/flang-rt/runtime/format.h
@@ -25,6 +25,8 @@ class Descriptor;
 
 namespace Fortran::runtime::io {
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 class IoStatementState;
 
 enum EditingFlags {
@@ -200,5 +202,8 @@ template <typename CONTEXT> class FormatControl {
   // must be last, may be incomplete
   Iteration stack_[maxMaxHeight];
 };
+
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime::io
 #endif // FLANG_RT_RUNTIME_FORMAT_H_

diff  --git a/flang-rt/include/flang-rt/runtime/internal-unit.h b/flang-rt/include/flang-rt/runtime/internal-unit.h
index 429d3489e0112..a046764153ad8 100644
--- a/flang-rt/include/flang-rt/runtime/internal-unit.h
+++ b/flang-rt/include/flang-rt/runtime/internal-unit.h
@@ -18,6 +18,8 @@
 
 namespace Fortran::runtime::io {
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 class IoErrorHandler;
 
 // Points to (but does not own) a CHARACTER scalar or array for internal I/O.
@@ -55,5 +57,8 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
 
 extern template class InternalDescriptorUnit<Direction::Output>;
 extern template class InternalDescriptorUnit<Direction::Input>;
+
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime::io
 #endif // FLANG_RT_RUNTIME_INTERNAL_UNIT_H_

diff  --git a/flang-rt/include/flang-rt/runtime/io-stmt.h b/flang-rt/include/flang-rt/runtime/io-stmt.h
index 73c59b0b5ed29..bfd5f69c76337 100644
--- a/flang-rt/include/flang-rt/runtime/io-stmt.h
+++ b/flang-rt/include/flang-rt/runtime/io-stmt.h
@@ -28,6 +28,8 @@
 
 namespace Fortran::runtime::io {
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 class ExternalFileUnit;
 class ChildIo;
 
@@ -880,5 +882,7 @@ class ErroneousIoStatementState : public IoStatementBase {
   ExternalFileUnit *unit_{nullptr};
 };
 
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime::io
 #endif // FLANG_RT_RUNTIME_IO_STMT_H_

diff  --git a/flang-rt/include/flang-rt/runtime/non-tbp-dio.h b/flang-rt/include/flang-rt/runtime/non-tbp-dio.h
index 2bbbfa7f97f79..99d4113b6c7a8 100644
--- a/flang-rt/include/flang-rt/runtime/non-tbp-dio.h
+++ b/flang-rt/include/flang-rt/runtime/non-tbp-dio.h
@@ -32,6 +32,8 @@ class DerivedType;
 
 namespace Fortran::runtime::io {
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 struct NonTbpDefinedIo {
   const typeInfo::DerivedType &derivedType;
   void (*subroutine)(); // null means no non-TBP defined I/O here
@@ -52,5 +54,7 @@ struct NonTbpDefinedIoTable {
   bool ignoreNonTbpEntries{false};
 };
 
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime::io
 #endif // FLANG_RT_RUNTIME_NON_TBP_DIO_H_

diff  --git a/flang-rt/include/flang-rt/runtime/work-queue.h b/flang-rt/include/flang-rt/runtime/work-queue.h
index 0daa7bc4d3384..124a87a772bbe 100644
--- a/flang-rt/include/flang-rt/runtime/work-queue.h
+++ b/flang-rt/include/flang-rt/runtime/work-queue.h
@@ -74,6 +74,8 @@ namespace Fortran::runtime {
 class Terminator;
 class WorkQueue;
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 // Ticket worker base classes
 
 template <typename TICKET> class ImmediateTicketRunner {
@@ -361,6 +363,7 @@ class DescriptorIoTicket
       : ImmediateTicketRunner<DescriptorIoTicket>(*this),
         Elementwise{descriptor}, io_{io}, table_{table},
         anyIoTookPlace_{anyIoTookPlace} {}
+
   RT_API_ATTRS int Begin(WorkQueue &);
   RT_API_ATTRS int Continue(WorkQueue &);
   RT_API_ATTRS bool &anyIoTookPlace() { return anyIoTookPlace_; }
@@ -551,5 +554,7 @@ class WorkQueue {
   TicketList *firstFree_{static_};
 };
 
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime
 #endif // FLANG_RT_RUNTIME_WORK_QUEUE_H_

diff  --git a/flang-rt/lib/runtime/edit-input.h b/flang-rt/lib/runtime/edit-input.h
index 686cd461b3e34..961f06569aca3 100644
--- a/flang-rt/lib/runtime/edit-input.h
+++ b/flang-rt/lib/runtime/edit-input.h
@@ -15,6 +15,8 @@
 
 namespace Fortran::runtime::io {
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 RT_API_ATTRS bool EditIntegerInput(
     IoStatementState &, const DataEdit &, void *, int kind, bool isSigned);
 
@@ -49,5 +51,7 @@ extern template RT_API_ATTRS bool EditCharacterInput(
 extern template RT_API_ATTRS bool EditCharacterInput(
     IoStatementState &, const DataEdit &, char32_t *, std::size_t);
 
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime::io
 #endif // FLANG_RT_RUNTIME_EDIT_INPUT_H_

diff  --git a/flang-rt/lib/runtime/edit-output.h b/flang-rt/lib/runtime/edit-output.h
index 51a47405e49e4..dbeccb291d363 100644
--- a/flang-rt/lib/runtime/edit-output.h
+++ b/flang-rt/lib/runtime/edit-output.h
@@ -25,6 +25,8 @@
 
 namespace Fortran::runtime::io {
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 // I, B, O, Z, and G output editing for INTEGER.
 // The DataEdit reference is const here (and elsewhere in this header) so that
 // one edit descriptor with a repeat factor may safely serve to edit
@@ -137,5 +139,7 @@ extern template class RealOutputEditing<10>;
 // TODO: double/double
 extern template class RealOutputEditing<16>;
 
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime::io
 #endif // FLANG_RT_RUNTIME_EDIT_OUTPUT_H_

diff  --git a/flang-rt/lib/runtime/unit.h b/flang-rt/lib/runtime/unit.h
index 86e5639f1250e..9aec9b1659576 100644
--- a/flang-rt/lib/runtime/unit.h
+++ b/flang-rt/lib/runtime/unit.h
@@ -46,6 +46,8 @@ extern RT_VAR_ATTRS ExternalFileUnit *defaultOutput; // unit 6
 extern RT_VAR_ATTRS ExternalFileUnit *errorOutput; // unit 0 extension
 RT_OFFLOAD_VAR_GROUP_END
 
+RT_OFFLOAD_API_GROUP_BEGIN
+
 #if defined(RT_USE_PSEUDO_FILE_UNIT)
 // A flavor of OpenFile class that pretends to be a terminal,
 // and only provides basic buffering of the output
@@ -298,5 +300,7 @@ class ChildIo {
   Fortran::common::optional<IoStatementState> io_;
 };
 
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::runtime::io
 #endif // FLANG_RT_RUNTIME_UNIT_H_

diff  --git a/flang/include/flang/Decimal/decimal.h b/flang/include/flang/Decimal/decimal.h
index 443163d058e28..5e81e47a18268 100644
--- a/flang/include/flang/Decimal/decimal.h
+++ b/flang/include/flang/Decimal/decimal.h
@@ -65,6 +65,9 @@ enum DecimalConversionFlags {
 #define EXTRA_DECIMAL_CONVERSION_SPACE (1 + 1 + 2 * 16 - 1)
 
 #ifdef __cplusplus
+
+RT_OFFLOAD_API_GROUP_BEGIN
+
 template <int PREC>
 RT_API_ATTRS ConversionToDecimalResult ConvertToDecimal(char *, size_t,
     DecimalConversionFlags, int digits, enum FortranRounding rounding,
@@ -110,6 +113,9 @@ extern template RT_API_ATTRS ConversionToBinaryResult<64> ConvertToBinary<64>(
     const char *&, enum FortranRounding, const char *end);
 extern template RT_API_ATTRS ConversionToBinaryResult<113> ConvertToBinary<113>(
     const char *&, enum FortranRounding, const char *end);
+
+RT_OFFLOAD_API_GROUP_END
+
 } // namespace Fortran::decimal
 extern "C" {
 #define NS(x) Fortran::decimal::x


        


More information about the flang-commits mailing list