public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106487] New: Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon)
@ 2022-07-31  5:00 apersaud at lbl dot gov
  2022-07-31  5:03 ` [Bug fortran/106487] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: apersaud at lbl dot gov @ 2022-07-31  5:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106487

            Bug ID: 106487
           Summary: Calls to ___builtin_nested_func_ptr_created that
                    cannot be resolved on M1 (Apple silicon)
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: apersaud at lbl dot gov
  Target Milestone: ---

I'm trying to compile a program (not public available) on an M1 and am running
in an issue where the linker is complaining about unknown functions

    U ___builtin_nested_func_ptr_created
    U ___builtin_nested_func_ptr_deleted

I'm using:

> gfortran-12 --version
GNU Fortran (Homebrew GCC 12.1.0_1) 12.1.0
[...]

Since I cannot share the source code. I tried to reduce it to a small program:
"""
MODULE focus
  IMPLICIT NONE
  PRIVATE

  PUBLIC  myinit
  ABSTRACT INTERFACE
     REAL(kind=8) FUNCTION dummyf(x)
       REAL(kind=8), INTENT(IN) :: x
     END FUNCTION dummyf
  end INTERFACE

CONTAINS

  SUBROUTINE myfun(fun,  x, res)
    ! return res = fun(x)
    IMPLICIT NONE
    PROCEDURE(dummyf) :: fun
    REAL(kind=8), INTENT(INOUT) :: x
    INTEGER, INTENT(OUT) :: res
    res = fun(x)
  end SUBROUTINE myfun

  SUBROUTINE myinit()
    IMPLICIT NONE
    INTEGER :: its, nfcalls
    REAL(kind=8) :: ftv

    CALL myfun(internal_func,  ftv,  its)
  CONTAINS
    FUNCTION internal_func(fv)
      IMPLICIT NONE
      REAL(kind=8), INTENT(IN) :: fv
      REAL(kind=8) :: internal_func
      !internal_func = nfcalls   ! create links to
___builtin_nested_func_ptr_created
      internal_func = 111        ! this works
    END FUNCTION internal_func
  END SUBROUTINE myinit

END MODULE focus
"""

The problem seems to be the function definition in the contains block of a
subroutine.
However, if this is not working on the M1, I would have expected some kind of
warning or error message, but the file compiles OK and only fails in a later
linker stage when the two mentioned functions cannot be found.

The command I used to compile was 
"gfortran-12 -m64 -O2 -c input.f95"

When I comment out the "internal_func = nfcalls" line and uncomment the
following line, the compiler does not link to these two functions (this only
works with the -O2 flag enabled though, so it probably just inlines the
function calls and therefore there is no CONTAINS block anymore?)

I'm not that familiar with fortran/gfortran...Not sure if this can/should be
fixed, but I thought I report it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/106487] Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon)
  2022-07-31  5:00 [Bug fortran/106487] New: Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon) apersaud at lbl dot gov
@ 2022-07-31  5:03 ` pinskia at gcc dot gnu.org
  2022-07-31 15:58 ` apersaud at lbl dot gov
  2022-07-31 20:16 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-31  5:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106487

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |MOVED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There is a github issue related to this already and this is not a fsf gcc
release.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/106487] Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon)
  2022-07-31  5:00 [Bug fortran/106487] New: Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon) apersaud at lbl dot gov
  2022-07-31  5:03 ` [Bug fortran/106487] " pinskia at gcc dot gnu.org
@ 2022-07-31 15:58 ` apersaud at lbl dot gov
  2022-07-31 20:16 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: apersaud at lbl dot gov @ 2022-07-31 15:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106487

--- Comment #2 from Arun Persaud <apersaud at lbl dot gov> ---
Thanks for the fast response... any chance to add a link to the issue you
mentioned or the repo?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/106487] Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon)
  2022-07-31  5:00 [Bug fortran/106487] New: Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon) apersaud at lbl dot gov
  2022-07-31  5:03 ` [Bug fortran/106487] " pinskia at gcc dot gnu.org
  2022-07-31 15:58 ` apersaud at lbl dot gov
@ 2022-07-31 20:16 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-07-31 20:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106487

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org,
                   |                            |iains at gcc dot gnu.org

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
Probably one of these; maybe Iain can tell us specifically which one:
https://github.com/iains/gcc-darwin-arm64/issues

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-31 20:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-31  5:00 [Bug fortran/106487] New: Calls to ___builtin_nested_func_ptr_created that cannot be resolved on M1 (Apple silicon) apersaud at lbl dot gov
2022-07-31  5:03 ` [Bug fortran/106487] " pinskia at gcc dot gnu.org
2022-07-31 15:58 ` apersaud at lbl dot gov
2022-07-31 20:16 ` egallager at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).