public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Bin.Cheng" <amker.cheng@gmail.com>
Cc: Steve Kargl <sgk@troutmask.apl.washington.edu>,
		Janne Blomqvist <blomqvist.janne@gmail.com>,
	Fortran List <fortran@gcc.gnu.org>,
		GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fortran -- clean up KILL
Date: Thu, 15 Mar 2018 12:35:00 -0000	[thread overview]
Message-ID: <CAFiYyc1vGbothBDgW_iHftEfD2QvwDrpMu+TvUnq4nVJ=NZPfg@mail.gmail.com> (raw)
In-Reply-To: <CAHFci29aZ3SK0GpsyPHmhOdSOp2ma4VCZNjDkaNtE6iZmDOk9g@mail.gmail.com>

On Thu, Mar 15, 2018 at 1:11 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Thu, Mar 15, 2018 at 10:18 AM, Bin.Cheng <amker.cheng@gmail.com> wrote:
>> On Wed, Mar 14, 2018 at 12:57 AM, Steve Kargl
>> <sgk@troutmask.apl.washington.edu> wrote:
>>> On Tue, Mar 13, 2018 at 09:49:10PM +0200, Janne Blomqvist wrote:
>>>>
>>>> int val = kill (pid, signal);
>>>> return (val == 0): 0 ? errno;
>>>>
>>>> like it already does for the optional status argument for kill_sub.
>>>>
>>>
>>> Committed as r258511 with your suggested change.
>> Hi Steve,
>>
>> After this change, AArch64/arm bare-metal cross (fortran) toolchain
>> fail to build with below error message:
>>
>> /.../obj/gcc2/./gcc/xgcc -B/.../obj/gcc2/./gcc/
>> -B/.../install/aarch64-none-elf/bin/
>> -B/.../install/aarch64-none-elf/lib/ -isystem
>> /.../install/aarch64-none-elf/include -isystem
>> /.../install/aarch64-none-elf/sys-include -DHAVE_CONFIG_H -I.
>> -I/.../gcc/libgfortran -iquote/.../gcc/libgfortran/io
>> -I/.../gcc/libgfortran/../gcc -I/.../gcc/libgfortran/../gcc/config
>> -I../../.././gcc -I/.../gcc/libgfortran/../libgcc -I../../libgcc
>> -I/.../gcc/libgfortran/../libbacktrace -I../../libbacktrace
>> -I../libbacktrace -std=gnu11 -Wall -Wstrict-prototypes
>> -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings
>> -Werror=implicit-function-declaration -Werror=vla -fcx-fortran-rules
>> -ffunction-sections -fdata-sections -g -ffunction-sections
>> -fdata-sections -O2 -mabi=ilp32 -MT kill.lo -MD -MP -MF .deps/kill.Tpo
>> -c /.../gcc/libgfortran/intrinsics/kill.c -o kill.o
>> /.../gcc/libgfortran/intrinsics/kill.c:54:22: error: conflicting types
>> for 'kill'
>>  extern GFC_INTEGER_4 kill (GFC_INTEGER_4, GFC_INTEGER_4);
>>                       ^~~~
>> In file included from /.../install/aarch64-none-elf/include/signal.h:6,
>>                  from /.../gcc/libgfortran/intrinsics/kill.c:28:
>> /.../install/aarch64-none-elf/include/sys/signal.h:176:5: note:
>> previous declaration of 'kill' was here
>>  int kill (pid_t, int);
>>      ^~~~
>> In file included from /.../gcc/libgfortran/intrinsics/kill.c:26:
>> /.../gcc/libgfortran/intrinsics/kill.c:55:14: error: conflicting types
>> for 'kill'
>>  export_proto(kill);
>>               ^~~~
>> /.../gcc/libgfortran/libgfortran.h:150:57: note: in definition of
>> macro 'sym_rename2'
>>  #define sym_rename2(old, ulp, new) extern __typeof(old) old __asm__(#ulp #new)
>>                                                          ^~~
>> /.../gcc/libgfortran/libgfortran.h:148:30: note: in expansion of macro
>> 'sym_rename1'
>>  #define sym_rename(old, new) sym_rename1(old, __USER_LABEL_PREFIX__, new)
>>                               ^~~~~~~~~~~
>> /.../gcc/libgfortran/libgfortran.h:195:26: note: in expansion of macro
>> 'sym_rename'
>>  # define export_proto(x) sym_rename(x, PREFIX(x))
>>                           ^~~~~~~~~~
>> /.../gcc/libgfortran/intrinsics/kill.c:55:1: note: in expansion of
>> macro 'export_proto'
>>  export_proto(kill);
>>  ^~~~~~~~~~~~
>> In file included from /.../install/aarch64-none-elf/include/signal.h:6,
>>                  from /.../gcc/libgfortran/intrinsics/kill.c:28:
>> /.../install/aarch64-none-elf/include/sys/signal.h:176:5: note:
>> previous declaration of 'kill' was here
>>  int kill (pid_t, int);
>>      ^~~~
>> /.../gcc/libgfortran/intrinsics/kill.c:58:1: error: conflicting types for 'kill'
>>  kill (GFC_INTEGER_4 pid, GFC_INTEGER_4 signal)
>>  ^~~~
>> In file included from /.../install/aarch64-none-elf/include/signal.h:6,
>>                  from /.../gcc/libgfortran/intrinsics/kill.c:28:
>> /.../install/aarch64-none-elf/include/sys/signal.h:176:5: note:
>> previous declaration of 'kill' was here
>>  int kill (pid_t, int);
>>      ^~~~
>>
>> The gcc is configured with:
>> gcc/configure --target=aarch64-none-elf --prefix=...
>> --with-gmp=.../host-tools --with-mpfr=.../host-tools
>> --with-mpc=.../host-tools --with-isl=.../host-tools
>> --with-pkgversion=unknown --disable-shared --disable-nls
>> --disable-threads --disable-tls --enable-checking=yes
>> --enable-languages=c,c++ --with-newlib
>> --enable-languages=c,c++,fortran
>>
>> I don't know fortran, so any suggestion how to fix this?
>> Note that -mabi=ilp32 is required to reproduce the breakage.
>
> So the pre-processed file for libgfortran/intrinsics/kill.c is like:
>
>
> int kill (pid_t, int);
>
> //......
>
> extern GFC_INTEGER_4 kill (GFC_INTEGER_4, GFC_INTEGER_4);
> extern __typeof(kill) kill __asm__("" "_gfortran_kill");

Why do you need to jump through these hoops anyway?  Just do ...

> GFC_INTEGER_4
> kill (GFC_INTEGER_4 pid, GFC_INTEGER_4 signal)

 _gfortran_kill (...

here.  The kill prototype should come via signal.h already.

I guess the issue is that libgfortran 'kill' (exported with _gfortran_ prefix)
aliases the POSIX kill and you even want to call that here.

So maybe just use export_proto_np or add another variant that works
on function definitions directly so you can write

GFC_INTEGER_4
export_def(kill) (GFC_INTEGER_4 ...)
{
}

> {
>   int val;
>   val = (int)kill (pid, signal);
>   return ((val == 0) ? 0 :
> # 62 "/.../gcc/libgfortran/intrinsics/kill.c" 3 4
>                           (*__errno())
> # 62 "/.../gcc/libgfortran/intrinsics/kill.c"
>                                );
> }
>
> I suppose fortran wants to define its own kill returning errorno
> directly on failure.
> The problem is below declaration:
>
> extern GFC_INTEGER_4 kill (GFC_INTEGER_4, GFC_INTEGER_4);
>
> could conflict with included c declaration which is:
>
> int kill (pid_t, int);
>
> Even GFC_INTEGER_4 is typedef as int32_t, we can't rely on that is the
> same as int type, right?
> In this case, int32_t is defined as long int on aarch64_ilp32 or arm
> bare-metal toolchains.
>
> Any idea to resolve the inconsistency?
>
> Thanks,
> bin
>>
>> Thanks,
>> bin
>>>
>>> --
>>> Steve

  parent reply	other threads:[~2018-03-15 12:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-11 16:52 Steve Kargl
2018-03-11 20:16 ` Janne Blomqvist
2018-03-11 20:42   ` Steve Kargl
2018-03-12 16:56     ` Janne Blomqvist
2018-03-12 17:37       ` Steve Kargl
2018-03-12 19:05         ` Janne Blomqvist
2018-03-13  4:08           ` Steve Kargl
2018-03-13 19:49             ` Janne Blomqvist
2018-03-14  0:57               ` Steve Kargl
2018-03-15 10:18                 ` Bin.Cheng
2018-03-15 12:11                   ` Bin.Cheng
2018-03-15 12:20                     ` Bin.Cheng
2018-03-15 15:07                       ` Steve Kargl
2018-03-15 12:35                     ` Richard Biener [this message]
2018-03-15 14:10                       ` Steve Kargl
2018-03-15 16:35                         ` Jakub Jelinek
2018-03-15 15:45                           ` Bin.Cheng
2018-03-15 17:35                             ` Jakub Jelinek
2018-03-15 15:57                               ` Bin.Cheng
2018-03-15 16:28                           ` Steve Kargl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc1vGbothBDgW_iHftEfD2QvwDrpMu+TvUnq4nVJ=NZPfg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=amker.cheng@gmail.com \
    --cc=blomqvist.janne@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sgk@troutmask.apl.washington.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).