public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0
@ 2022-05-13 21:06 mario_grgic at hotmail dot com
  2022-05-13 22:05 ` [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: mario_grgic at hotmail dot com @ 2022-05-13 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105599
           Summary: g++ binary: undefined symbols _main referenced from
                    __start in crt1.0
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mario_grgic at hotmail dot com
  Target Milestone: ---

I have compiled gcc 12.1.0 from source on macOS 10.15.7 (Catalina) with XCode
12.1. I used the following configuration:

```
../configure --prefix=/usr/local --with-gmp=/usr/local --with-mpfr=/usr/local
--with-mpc=/usr/local --with-isl-prefix=/usr/local --with-cloog=/usr/local
--enable-checking=release --enable-languages=c,c++,fortran
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
--with-system-zlib --with-zsstd=/usr/local --disable-multilib --disable-nls 

```

Everything builds and installs correctly. gcc and other binaries work, however
invoking g++ without any arguments produces

```
$ /usr/local/bin/g++
Undefined symbols for architecture x86_64:
  "_main", referenced from:
      __start in crt1.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
```

Note that g++ works correctly and compiles and produces working binaries when
invoked with correct arguments.

Similar thing happens with c++ binary.

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
@ 2022-05-13 22:05 ` pinskia at gcc dot gnu.org
  2022-05-13 22:21 ` iains at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-13 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |target
           Keywords|                            |diagnostic
            Summary|g++ binary: undefined       |g++ by itself is not
                   |symbols _main referenced    |producing "fatal error: no
                   |from __start in crt1.0      |input files" for darwin
                   |                            |target
             Target|                            |x86_64-darwin*
           Severity|normal                      |trivial

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
On Linux this produces:
apinski@xeond:~/src/p4/octeontxkpu$ ~/upstream-gcc/bin/g++
g++: fatal error: no input files
compilation terminated.

So it is a darwin specific issue but it is a minor one as it is just a
diagnostic issue with invalid invocation anyways.

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
  2022-05-13 22:05 ` [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target pinskia at gcc dot gnu.org
@ 2022-05-13 22:21 ` iains at gcc dot gnu.org
  2022-05-13 23:03 ` iains at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2022-05-13 22:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
hmm .. that issue had been found and fixed, I will have to check what happened.

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
  2022-05-13 22:05 ` [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target pinskia at gcc dot gnu.org
  2022-05-13 22:21 ` iains at gcc dot gnu.org
@ 2022-05-13 23:03 ` iains at gcc dot gnu.org
  2022-05-29 18:27 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2022-05-13 23:03 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-05-13
     Ever confirmed|0                           |1

--- Comment #3 from Iain Sandoe <iains at gcc dot gnu.org> ---
gcc version 12.0.1 20220429 (prerelease) [gcc-12-1rc1 revision
r12-8321-g621650f64fb6] (GCC) 
gcc-12-1-darwin mini-07-cat:gcc-git-12 isandoe$
/opt/iains/x86_64-apple-darwin19/gcc-12-1rc1/bin/gcc
gcc: fatal error: no input files
compilation terminated.

$ /opt/iains/x86_64-apple-darwin19/gcc-12-1rc1/bin/g++
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: error: ld returned 1 exit status

So, we have some addition to the command line from the g++ driver that is
causing this (the actual reported problem is not significant, the reason is
that the command line is not being seen as empty by the darwin driver)

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
                   ` (2 preceding siblings ...)
  2022-05-13 23:03 ` iains at gcc dot gnu.org
@ 2022-05-29 18:27 ` cvs-commit at gcc dot gnu.org
  2022-06-15 19:07 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-29 18:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:794737976b9a6418eab817f143bb4eb2d0c834d2

commit r13-818-g794737976b9a6418eab817f143bb4eb2d0c834d2
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun May 29 16:14:32 2022 +0100

    Darwin: Fix empty g++ command lines [PR105599].

    An empty g++ command line should produce a diagnostic that there are no
    inputs.  The PR is that currently Darwin produces a dignostic about missing
    link items instead - this is because (errnoeously), for this driver, we are
    creating a link job for empty command lines.

    The problem occurs in four stages:

     The g++ driver appends -shared-libgcc to the command line.

     The Darwin driver_init code in the backend does not see this (it sees an
     empty command line).

     When the back end driver code driver sees an empty command line, it does
not
     add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
     avoid anything being claimed as an input_file and therefore triggering a
link
     line.

     Since we do not have a value for asm-macosx-version-min when processing
the
     driver specs, we unconditionally inject 'multiply_defined suppress' which
is
     used with shared libgcc (but only intended on very old Darwin).  This then
     causes the generation of a link job.

    The solution, for the present, is to move version-specific link params to
the
    LINK_SPEC so that they are only processed when a link job has already been
    decided.

    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

            PR target/105599

    gcc/ChangeLog:

            * config/darwin.h: Move versions-specific handling of
multiply_defined
            from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
                   ` (3 preceding siblings ...)
  2022-05-29 18:27 ` cvs-commit at gcc dot gnu.org
@ 2022-06-15 19:07 ` cvs-commit at gcc dot gnu.org
  2022-06-15 19:09 ` iains at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-15 19:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:58c0bc2b62cdbbe9d9677b448fe52a8c54044276

commit r12-8484-g58c0bc2b62cdbbe9d9677b448fe52a8c54044276
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun May 29 16:14:32 2022 +0100

    Darwin: Fix empty g++ command lines [PR105599].

    An empty g++ command line should produce a diagnostic that there are no
    inputs.  The PR is that currently Darwin produces a dignostic about missing
    link items instead - this is because (errnoeously), for this driver, we are
    creating a link job for empty command lines.

    The problem occurs in four stages:

     The g++ driver appends -shared-libgcc to the command line.

     The Darwin driver_init code in the backend does not see this (it sees an
     empty command line).

     When the back end driver code driver sees an empty command line, it does
not
     add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
     avoid anything being claimed as an input_file and therefore triggering a
link
     line.

     Since we do not have a value for asm-macosx-version-min when processing
the
     driver specs, we unconditionally inject 'multiply_defined suppress' which
is
     used with shared libgcc (but only intended on very old Darwin).  This then
     causes the generation of a link job.

    The solution, for the present, is to move version-specific link params to
the
    LINK_SPEC so that they are only processed when a link job has already been
    decided.

    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

            PR target/105599

    gcc/ChangeLog:

            * config/darwin.h: Move versions-specific handling of
multiply_defined
            from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.

    (cherry picked from commit 794737976b9a6418eab817f143bb4eb2d0c834d2)

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
                   ` (4 preceding siblings ...)
  2022-06-15 19:07 ` cvs-commit at gcc dot gnu.org
@ 2022-06-15 19:09 ` iains at gcc dot gnu.org
  2023-05-16 19:01 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2022-06-15 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
needed on 11.x

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
                   ` (5 preceding siblings ...)
  2022-06-15 19:09 ` iains at gcc dot gnu.org
@ 2023-05-16 19:01 ` cvs-commit at gcc dot gnu.org
  2023-05-16 19:10 ` iains at gcc dot gnu.org
  2024-04-24 18:36 ` cvs-commit at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-16 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:a8307cfd66d29efae9c28f5b32bd677398c92dfe

commit r11-10780-ga8307cfd66d29efae9c28f5b32bd677398c92dfe
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun May 29 16:14:32 2022 +0100

    Darwin: Fix empty g++ command lines [PR105599].

    An empty g++ command line should produce a diagnostic that there are no
    inputs.  The PR is that currently Darwin produces a dignostic about missing
    link items instead - this is because (errnoeously), for this driver, we are
    creating a link job for empty command lines.

    The problem occurs in four stages:

     The g++ driver appends -shared-libgcc to the command line.

     The Darwin driver_init code in the backend does not see this (it sees an
     empty command line).

     When the back end driver code driver sees an empty command line, it does
not
     add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
     avoid anything being claimed as an input_file and therefore triggering a
link
     line.

     Since we do not have a value for asm-macosx-version-min when processing
the
     driver specs, we unconditionally inject 'multiply_defined suppress' which
is
     used with shared libgcc (but only intended on very old Darwin).  This then
     causes the generation of a link job.

    The solution, for the present, is to move version-specific link params to
the
    LINK_SPEC so that they are only processed when a link job has already been
    decided.

    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

            PR target/105599

    gcc/ChangeLog:

            * config/darwin.h: Move versions-specific handling of
multiply_defined
            from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.

    (cherry picked from commit 794737976b9a6418eab817f143bb4eb2d0c834d2)

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
                   ` (6 preceding siblings ...)
  2023-05-16 19:01 ` cvs-commit at gcc dot gnu.org
@ 2023-05-16 19:10 ` iains at gcc dot gnu.org
  2024-04-24 18:36 ` cvs-commit at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2023-05-16 19:10 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from Iain Sandoe <iains at gcc dot gnu.org> ---
fixed for affected open branches

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

* [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target
  2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
                   ` (7 preceding siblings ...)
  2023-05-16 19:10 ` iains at gcc dot gnu.org
@ 2024-04-24 18:36 ` cvs-commit at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-24 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:3bb14f6ed5bc70e25381c67963c90eaab91eca22

commit r11-11353-g3bb14f6ed5bc70e25381c67963c90eaab91eca22
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun May 29 16:14:32 2022 +0100

    Darwin: Fix empty g++ command lines [PR105599].

    An empty g++ command line should produce a diagnostic that there are no
    inputs.  The PR is that currently Darwin produces a dignostic about missing
    link items instead - this is because (errnoeously), for this driver, we are
    creating a link job for empty command lines.

    The problem occurs in four stages:

     The g++ driver appends -shared-libgcc to the command line.

     The Darwin driver_init code in the backend does not see this (it sees an
     empty command line).

     When the back end driver code driver sees an empty command line, it does
not
     add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
     avoid anything being claimed as an input_file and therefore triggering a
link
     line.

     Since we do not have a value for asm-macosx-version-min when processing
the
     driver specs, we unconditionally inject 'multiply_defined suppress' which
is
     used with shared libgcc (but only intended on very old Darwin).  This then
     causes the generation of a link job.

    The solution, for the present, is to move version-specific link params to
the
    LINK_SPEC so that they are only processed when a link job has already been
    decided.

    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

            PR target/105599

    gcc/ChangeLog:

            * config/darwin.h: Move versions-specific handling of
multiply_defined
            from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.

    (cherry picked from commit 794737976b9a6418eab817f143bb4eb2d0c834d2)

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

end of thread, other threads:[~2024-04-24 18:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 21:06 [Bug c++/105599] New: g++ binary: undefined symbols _main referenced from __start in crt1.0 mario_grgic at hotmail dot com
2022-05-13 22:05 ` [Bug target/105599] g++ by itself is not producing "fatal error: no input files" for darwin target pinskia at gcc dot gnu.org
2022-05-13 22:21 ` iains at gcc dot gnu.org
2022-05-13 23:03 ` iains at gcc dot gnu.org
2022-05-29 18:27 ` cvs-commit at gcc dot gnu.org
2022-06-15 19:07 ` cvs-commit at gcc dot gnu.org
2022-06-15 19:09 ` iains at gcc dot gnu.org
2023-05-16 19:01 ` cvs-commit at gcc dot gnu.org
2023-05-16 19:10 ` iains at gcc dot gnu.org
2024-04-24 18:36 ` cvs-commit 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).