Opened 14 months ago

Last modified 2 months ago

#72156 assigned defect

flang-19, flang-20: fails to build on 10.15, 10.13, 10.11

Reported by: jmroot (Joshua Root) Owned by: cjones051073 (Chris Jones)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mascguy (Christopher Nielsen), Dave-Allured (Dave Allured), cooljeanius (Eric Gallager)
Port: flang-19 flang-20 llvm-20

Description

With clang-14:

/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/runtime/time-intrinsic.cpp:148:28: error: use of undeclared identifier 'TIME_UTC'
  if (timespec_get(&tspec, TIME_UTC) < 0) {
                           ^

https://build.macports.org/builders/ports-10.15_x86_64-builder/builds/207211/steps/install-port/logs/stdio

With clang-16:

In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/lib/Optimizer/Dialect/Support/FIRContext.cpp:13:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/include/flang/Optimizer/Dialect/Support/FIRContext.h:20:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/../mlir/include/mlir/Dialect/LLVMIR/LLVMAttrs.h:17:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/../mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h:17:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/../mlir/include/mlir/IR/Types.h:12:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/../mlir/include/mlir/IR/TypeSupport.h:16:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/../mlir/include/mlir/IR/MLIRContext.h:12:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/flang/../mlir/include/mlir/Support/LLVM.h:23:
In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/llvm/include/llvm/Support/Casting.h:20:
In file included from /opt/local/libexec/llvm-16/bin/../include/c++/v1/memory:884:
In file included from /opt/local/libexec/llvm-16/bin/../include/c++/v1/__memory/allocate_at_least.h:13:
In file included from /opt/local/libexec/llvm-16/bin/../include/c++/v1/__memory/allocator_traits.h:14:
In file included from /opt/local/libexec/llvm-16/bin/../include/c++/v1/__memory/construct_at.h:23:
/opt/local/libexec/llvm-16/bin/../include/c++/v1/new:355:14: error: no member named 'aligned_alloc' in the global namespace
    return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size);
           ~~^

https://build.macports.org/builders/ports-10.15_x86_64-builder/builds/207244/steps/install-port/logs/stdio

The latter is #69699 which appears to have been fixed in LLVM 17.

Change History (9)

comment:1 Changed 14 months ago by jmroot (Joshua Root)

Also failing on 10.11:

In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/compiler-rt/lib/fuzzer/FuzzerCrossOver.cpp:11:
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_llvm-20/flang-20/work/llvm-project-20.1.0.src/compiler-rt/lib/fuzzer/FuzzerDefs.h:14:10: fatal error: 'cassert' file not found
   14 | #include <cassert>
      |          ^~~~~~~~~
1 error generated.

comment:2 Changed 14 months ago by mascguy (Christopher Nielsen)

Cc: mascguy added
Summary: flang-20 failed to build on 10.15flang-20: fails to build on 10.15, 10.13, 10.11

Also failing on 10.13, with the same cassert issue as 10.11

comment:3 Changed 9 months ago by ryandesign (Ryan Carsten Schmidt)

Also causing the macOS 11 arm64 buildbot worker to kernel panic; #72847.

comment:4 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)

Port: flang-19 added
Summary: flang-20: fails to build on 10.15, 10.13, 10.11flang-19, flang-20: fails to build on 10.15, 10.13, 10.11

comment:5 Changed 5 months ago by Dave-Allured (Dave Allured)

Cc: Dave-Allured added

comment:6 Changed 3 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:7 Changed 2 months ago by tomio-arisaka (Tomio Arisaka)

On macOS High Sierra, I was able to build flang-20 after applying the following patches:

$ diff -u llvm-20.orig/Portfile llvm-20/Portfile 
--- llvm-20.orig/Portfile	2025-10-09 07:28:31.000000000 +0900
+++ llvm-20/Portfile	2026-02-26 17:25:40.000000000 +0900
@@ -306,6 +306,38 @@
 
     # https://trac.macports.org/ticket/72954
     build.mem_per_job   4700
+
+    if {${os.platform} eq "darwin" && ${os.major} < 19} {
+        # use C++ header files included in the specific version of clang instead of macports-libcxx
+        # in order to avoid an error
+        set llvmversion         17
+        depends_build-append    port:clang-${llvmversion}
+        depends_lib-append      port:macports-libcxx
+        
+        configure.cflags-append \
+            -isystem${workpath}/include/c++/v1 \
+            -nostdinc++ \
+            -isystem/opt/local/include/LegacySupport
+        configure.cxxflags-append \
+            -isystem${workpath}/include/c++/v1 \
+            -nostdinc++ \
+            -isystem/opt/local/include/LegacySupport \
+            -stdlib=libc++
+        configure.ldflags-append \
+            -L${prefix}/lib/libcxx
+
+        build.env-append \
+            CFLAGS=${configure.cflags} \
+            CXXFLAGS=${configure.cxxflags} \
+            LDFLAGS=${configure.ldflags}
+
+        post-extract {
+            system -W ${workpath} "mkdir -p ./include/c++"
+            copy  ${prefix}/libexec/llvm-${llvmversion}/include/c++/v1 ${workpath}/include/c++/
+            # disable Apple libc++ availability tests, as we're using a new libc++ with these headers
+            system -W ${workpath}/include/c++/v1 "patch -p0 < ${filespath}/patch-disable-availability.diff"
+        }
+    }
 }
 
 if { ${subport} eq "clang-${llvm_version}" || ${subport} eq "flang-${llvm_version}" } {
$ cat ./llvm-20/files/patch-disable-availability.diff 
--- __config.orig	2023-11-28 17:52:28.000000000 +0900
+++ __config	2026-02-09 03:50:00.000000000 +0900
@@ -33,6 +33,9 @@
 #  define _LIBCPP_COMPILER_GCC
 #endif
 
+// we are not going to use Apple Availability testing in these headers
+#define _LIBCPP_DISABLE_AVAILABILITY
+
 #ifdef __cplusplus
 
 // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html

So I got flang-20:

$ port -v installed flang-20
The following ports are currently installed:
  flang-20 @20.1.8_0 (active) requested_variants='' platform='darwin 17' archs='x86_64' date='2026-02-26T19:57:29+0900'

comment:8 in reply to:  7 Changed 2 months ago by tomio-arisaka (Tomio Arisaka)

Replying to tomio-arisaka:

On macOS High Sierra, I was able to build flang-20 after applying the following patches:

I was able to build flang-21 with the same way.

$ port -v installed flang-21
The following ports are currently installed:
  flang-21 @21.1.8_0 (active) requested_variants='' platform='darwin 17' archs='x86_64' date='2026-03-01T05:29:59+0900'

comment:9 Changed 2 months ago by cjones051073 (Chris Jones)

If someone able to test (i.e. has an older OS) opens a PR with the required changes they can be reviewed.

Note: See TracTickets for help on using tickets.