This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/68605] New: Add -mno-crt0 to disable automatic crt0 injection


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

            Bug ID: 68605
           Summary: Add -mno-crt0 to disable automatic crt0 injection
           Product: gcc
           Version: 4.9.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rdiezmail-gcc at yahoo dot de
  Target Milestone: ---

I am developing embedded software on an ARM Cortex-M3 CPU without an OS ('bare
metal') using newlib. I am not using libgloss, sometimes because the boards
need custom start-up code, partly because they have 2 firmware versions (normal
and emergency). On other scenarios, libgloss is just not worth the trouble.

GCC insists on adding crt0.o to the list of objects to link, which libgloss
tends to provide. I haven't got such a file, and I do not need one, as
everything is provided somewhere else. Due to limitations in the autotools, I
have to provide an empty crt0 on every makefile. An example is here, just
search for "crt0" on the following page:

https://github.com/rdiez/JtagDue/blob/master/Project/JtagFirmware/Makefile.am

I am not the only one hitting this problem, search the Internet for [gcc crt0]
and you'll find many hits. Working around this issue has made enough people
waste enough time.

I guess quietly and forcibly adding an object file to the list of things to
link is still there for historical reasons, but it does not make it any less of
a bad practice.

Some GCC targets have flag -mno-crt0 to alleviate the problem, others allow you
to change the name from crt0 to something else. I would welcome a flag like
-mno-crt0 for all architectures, or at least for ARM, which is what is bugging
me at the moment.

I have seen that some ARM toolchain patches GCC to remove the crt0 injection,
but I like building the GCC toolchain myself, and patching this every time is
unnecessary work.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]