LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 6364 - gcc option -fno-toplevel-reorder separates top level inline asm which affects eglibc
Summary: gcc option -fno-toplevel-reorder separates top level inline asm which affects...
Status: RESOLVED WONTFIX
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: 2.6
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
: 27688 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-02-21 11:20 PST by Sergey Yakoushkin
Modified: 2016-05-09 15:10 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
source used to create crt code in eglibc (47.64 KB, text/plain)
2010-02-21 11:20 PST, Sergey Yakoushkin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Yakoushkin 2010-02-21 11:20:06 PST
Created attachment 4261 [details]
source used to create crt code in eglibc

-fno-toplevel-reorder option is used with by eglibc library (libc/csu) to generate init/fini code for ctr*.

> llvm-gcc initfini.c -c -std=gnu99 -fgnu89-inline -O0 -Wall -Winline -Wwrite-strings -fmerge-all-constants -Wstrict-prototypes -mpreferred-stack-boundary=4 -DHAVE_INITFINI -S -g0 -fPIC -fno-inline-functions -fno-toplevel-reorder -fno-section-anchors -finhibit-size-directive -fno-exceptions -o initfini.s

C source file comes with inlined asm having special markup. C is compiled into asm and then gawk is used to strip different parts for different crt* files.

However, llvm outputs all top level inlined asm separately in AsmPrinter::doInitialization, and after it outputs all functions. Which results in eglibc fail to build with llvm.


initfini.c fragment:

 asm (".section " ".init" );

 extern void __attribute__ ((section (".init"))) _init (void);
 void
 _init (void)
 {
  call_gmon_start ();

  asm ("ALIGN");
  asm("END_INIT");

  asm ("\n/*@_init_PROLOG_ENDS*/");
  asm ("\n/*@_init_EPILOG_BEGINS*/");
  asm (".section " ".init" );
 }
 asm ("END_INIT");
 asm ("\n/*@_init_EPILOG_ENDS*/");
 asm ("\n/*@_fini_PROLOG_BEGINS*/");
Comment 1 Anton Korobeynikov 2010-02-21 12:24:07 PST
We do not support this flag, and I really doubt this will happen one day.
Comment 2 Chris Lattner 2010-02-21 12:43:22 PST
Right, this flag is deprecated by GCC and we have no intention of implementing it.  The code should be fixed to not depend on it.
Comment 3 Sergey Yakoushkin 2010-02-21 13:46:46 PST
Are there existing patches for glibc/eglibc for llvm?

BTW. Are there any technical issues to support option?

(In reply to comment #2)
> Right, this flag is deprecated by GCC and we have no intention of implementing
> it.  The code should be fixed to not depend on it.
Comment 4 Chris Lattner 2010-02-21 13:48:23 PST
I don't know if there are patches, there are many technical reasons to not support this.  We don't track the order of inline asm vs functions.  Adding it would be significant implementation effort for an option that is deprecated (and never really made sense).
Comment 5 Sergey Yakoushkin 2010-02-21 14:05:10 PST
Thanks for your answer, Chris. Ok, option support seems to be unlikely.
But I don't think I'm the first one facing issues with C libraries build. Haven't found info on the web yet. Is there any support person for that? Or appropriate topic to discuss?
Comment 6 Chris Lattner 2010-02-21 14:22:52 PST
I don't really know, but you can definitely email llvmdev and ask if others have any idea
Comment 7 Sergey Yakoushkin 2010-02-21 18:31:28 PST
Wouldn't simple saving of initial lexical order in parser be enough to reorder inlined top level asm to output correctly?

I've contacted eglibc maintainers and got the following answer. Seems they expect this option to be supported by compilers:

2010/2/22 Joseph S. Myers <joseph@codesourcery.com>:
> On Mon, 22 Feb 2010, Sergey Yakoushkin wrote:
>
>> This option might become deprecated in gcc (~v 4.6),
>
> That seems an *extremely* unlikely speculation.  What actual evidence from
> GCC development discussions do you have for it?  I think someone has got
> confused by some old discussions of -fno-toplevel-reorder as the
> replacement for deprecated -fno-unit-at-a-time into thinking it's
> -fno-toplevel-reorder that's deprecated; it's not and is hardly likely to
> be.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>
Comment 8 Reid Kleckner 2016-05-09 15:10:40 PDT
*** Bug 27688 has been marked as a duplicate of this bug. ***