Index: flang/include/flang/ISO_Fortran_binding.h =================================================================== --- flang/include/flang/ISO_Fortran_binding.h +++ flang/include/flang/ISO_Fortran_binding.h @@ -18,7 +18,9 @@ * implementation. */ -#include "Runtime/api-attrs.h" +#ifndef RT_API_ATTRS +#define RT_API_ATTRS +#endif #ifdef __cplusplus namespace Fortran { Index: flang/include/flang/ISO_Fortran_binding_wrapper.h =================================================================== --- /dev/null +++ flang/include/flang/ISO_Fortran_binding_wrapper.h @@ -0,0 +1,29 @@ +/*===-- include/flang/ISO_Fortran_binding_wrapper.h ---------------*- C++ -*-=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + * ===-----------------------------------------------------------------------=== + */ + +#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ +#define FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ + +/* A thin wrapper around flang/include/ISO_Fortran_binding.h + * This header file must be included when ISO_Fortran_binding.h + * definitions/declarations are needed in Flang compiler/runtime + * sources. The inclusion of Runtime/api-attrs.h below sets up + * proper values for the macros used in ISO_Fortran_binding.h + * for the device offload builds. + * flang/include/ISO_Fortran_binding.h is made a standalone + * header file so that it can be used on its own in users' + * C/C++ programs. + */ + +/* clang-format off */ +#include "Runtime/api-attrs.h" +#include "ISO_Fortran_binding.h" +/* clang-format on */ + +#endif /* FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_ */ Index: flang/include/flang/Optimizer/Support/TypeCode.h =================================================================== --- flang/include/flang/Optimizer/Support/TypeCode.h +++ flang/include/flang/Optimizer/Support/TypeCode.h @@ -13,7 +13,7 @@ #ifndef FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H #define FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "llvm/Support/ErrorHandling.h" namespace fir { Index: flang/include/flang/Runtime/descriptor.h =================================================================== --- flang/include/flang/Runtime/descriptor.h +++ flang/include/flang/Runtime/descriptor.h @@ -18,7 +18,7 @@ // User C code is welcome to depend on that ISO_Fortran_binding.h file, // but should never reference this internal header. -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/memory.h" #include "flang/Runtime/type-code.h" #include Index: flang/include/flang/Runtime/type-code.h =================================================================== --- flang/include/flang/Runtime/type-code.h +++ flang/include/flang/Runtime/type-code.h @@ -10,7 +10,7 @@ #define FORTRAN_RUNTIME_TYPE_CODE_H_ #include "flang/Common/Fortran.h" -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include #include Index: flang/lib/Optimizer/CodeGen/CodeGen.cpp =================================================================== --- flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -13,7 +13,6 @@ #include "flang/Optimizer/CodeGen/CodeGen.h" #include "CGOps.h" -#include "flang/ISO_Fortran_binding.h" #include "flang/Optimizer/Dialect/FIRAttr.h" #include "flang/Optimizer/Dialect/FIROps.h" #include "flang/Optimizer/Dialect/FIRType.h" Index: flang/lib/Optimizer/CodeGen/DescriptorModel.h =================================================================== --- flang/lib/Optimizer/CodeGen/DescriptorModel.h +++ flang/lib/Optimizer/CodeGen/DescriptorModel.h @@ -22,7 +22,7 @@ #ifndef OPTIMIZER_DESCRIPTOR_MODEL_H #define OPTIMIZER_DESCRIPTOR_MODEL_H -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/descriptor.h" #include "mlir/Dialect/LLVMIR/LLVMTypes.h" #include "mlir/IR/BuiltinTypes.h" Index: flang/lib/Optimizer/Dialect/FIRType.cpp =================================================================== --- flang/lib/Optimizer/Dialect/FIRType.cpp +++ flang/lib/Optimizer/Dialect/FIRType.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include "flang/Optimizer/Dialect/FIRType.h" -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Optimizer/Dialect/FIRDialect.h" #include "flang/Optimizer/Dialect/Support/KindMapping.h" #include "flang/Tools/PointerModels.h" Index: flang/lib/Optimizer/Transforms/LoopVersioning.cpp =================================================================== --- flang/lib/Optimizer/Transforms/LoopVersioning.cpp +++ flang/lib/Optimizer/Transforms/LoopVersioning.cpp @@ -40,7 +40,7 @@ /// could be part of the cost analysis above. //===----------------------------------------------------------------------===// -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Optimizer/Builder/BoxValue.h" #include "flang/Optimizer/Builder/FIRBuilder.h" #include "flang/Optimizer/Builder/Runtime/Inquiry.h" Index: flang/runtime/ISO_Fortran_binding.cpp =================================================================== --- flang/runtime/ISO_Fortran_binding.cpp +++ flang/runtime/ISO_Fortran_binding.cpp @@ -9,9 +9,9 @@ // Implements the required interoperability API from ISO_Fortran_binding.h // as specified in section 18.5.5 of Fortran 2018. -#include "flang/ISO_Fortran_binding.h" #include "ISO_Fortran_util.h" #include "terminator.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/descriptor.h" #include "flang/Runtime/type-code.h" #include Index: flang/runtime/ISO_Fortran_util.h =================================================================== --- flang/runtime/ISO_Fortran_util.h +++ flang/runtime/ISO_Fortran_util.h @@ -12,7 +12,7 @@ // Internal utils for establishing CFI_cdesc_t descriptors. #include "terminator.h" -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/descriptor.h" #include "flang/Runtime/type-code.h" #include Index: flang/runtime/allocatable.cpp =================================================================== --- flang/runtime/allocatable.cpp +++ flang/runtime/allocatable.cpp @@ -12,7 +12,7 @@ #include "stat.h" #include "terminator.h" #include "type-info.h" -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/assign.h" #include "flang/Runtime/descriptor.h" Index: flang/runtime/stat.h =================================================================== --- flang/runtime/stat.h +++ flang/runtime/stat.h @@ -11,7 +11,7 @@ #ifndef FORTRAN_RUNTIME_STAT_H_ #define FORTRAN_RUNTIME_STAT_H_ -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/magic-numbers.h" namespace Fortran::runtime { Index: flang/runtime/temporary-stack.cpp =================================================================== --- flang/runtime/temporary-stack.cpp +++ flang/runtime/temporary-stack.cpp @@ -11,7 +11,7 @@ #include "flang/Runtime/temporary-stack.h" #include "terminator.h" -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/assign.h" #include "flang/Runtime/descriptor.h" #include "flang/Runtime/memory.h" Index: flang/unittests/Evaluate/ISO-Fortran-binding.cpp =================================================================== --- flang/unittests/Evaluate/ISO-Fortran-binding.cpp +++ flang/unittests/Evaluate/ISO-Fortran-binding.cpp @@ -1,5 +1,5 @@ #include "testing.h" -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/descriptor.h" #include "llvm/Support/raw_ostream.h" #include Index: flang/unittests/Runtime/TemporaryStack.cpp =================================================================== --- flang/unittests/Runtime/TemporaryStack.cpp +++ flang/unittests/Runtime/TemporaryStack.cpp @@ -8,7 +8,7 @@ #include "gtest/gtest.h" #include "tools.h" -#include "flang/ISO_Fortran_binding.h" +#include "flang/ISO_Fortran_binding_wrapper.h" #include "flang/Runtime/allocatable.h" #include "flang/Runtime/cpp-type.h" #include "flang/Runtime/descriptor.h"