chapel
chapel copied to clipboard
Internal compiler error when attempting Chapel calling Fortran
This is not a show stopper at this point. Current work around is to not include the header file on the compilation command. Of course then I get a linking error, but that is for another github issue.
Steps to Reproduce
Source Code:
// example.chpl
// extern declaration of a function in exampleLib.f90
pragma "generate signature"
extern proc myfunc(formal1 : real, formal2 : int) : real;
var answer = myfunc(2.0, 3);
writeln("answer should be 8.0, answer = ", answer);
! exampleLib.f90
module TestProcs
use iso_c_binding
implicit none
contains
double precision function myfunc(formal1, formal2) bind(C,name='myfunc')
double precision formal1
integer formal2
double precision power
integer i
!real(8), bind(C, name='power') :: power = 1.0
power = 1.0d0
do i = 0, formal2 - 1
power = power * formal1
end do
myfunc = power
end function myfunc
end module TestProcs
// exampleLib.h
double myfunc(double formal1, int formal2);
Compile command:
gfortran -c exampleLib.f90
chpl exampleLib.h exampleLib.o example.chpl
example.chpl:4: internal error: COD-CG--BOL-2313 chpl version 1.32.0
Internal errors indicate a bug in the Chapel compiler,
and we're sorry for the hassle. We would appreciate your reporting this bug --
please see https://chapel-lang.org/bugs.html for instructions. In the meantime,
the filename + line number above may be useful in working around the issue.
Configuration Information
chpl --version
chpl version 1.32.0
built with LLVM version 15.0.7
available LLVM targets: xcore, x86-64, x86, wasm64, wasm32, ve, systemz, sparcel, sparcv9, sparc, riscv64, riscv32, ppc64le, ppc64, ppc32le, ppc32, nvptx64, nvptx, msp430, mips64el, mips64, mipsel, mips, lanai, hexagon, bpfeb, bpfel, bpf, avr, thumbeb, thumb, armeb, arm, amdgcn, r600, aarch64_32, aarch64_be, aarch64, arm64_32, arm64
Copyright 2020-2023 Hewlett Packard Enterprise Development LP
Copyright 2004-2019 Cray Inc.
(See LICENSE file for more details)
gfortran --version
GNU Fortran (Homebrew GCC 13.2.0) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.