Fix test-as-const-jmp_buf-ssp.c generation on gnu-i386

Message ID 20181201231247.p7z3veulcqxfd2o2@function
State Committed, archived
Headers

Commit Message

Samuel Thibault Dec. 1, 2018, 11:12 p.m. UTC
  hurd's jmp_buf-ssp.sym does not define any symbol.
scripts/gen-as-const.py currently was emitting an empty line in that
case, and the gawk invocation was prepending "asconst_" to it, ending up
with:

.../build/glibc/setjmp/test-as-const-jmp_buf-ssp.c:1:2: error: expected « = », « , », « ; », « asm » or « __attribute__ » at end of input
    1 |  asconst_
      |  ^~~~~~~~

2018-12-01  Samuel Thibault  <samuel.thibault@ens-lyon.org>

	* scripts/gen-as-const.py (main): Avoid emitting empty line when
	there is no element in `consts'.
  

Comments

Samuel Thibault Dec. 1, 2018, 11:44 p.m. UTC | #1
Samuel Thibault, le dim. 02 déc. 2018 00:12:47 +0100, a ecrit:
> hurd's jmp_buf-ssp.sym does not define any symbol.
> scripts/gen-as-const.py currently was emitting an empty line in that
> case, and the gawk invocation was prepending "asconst_" to it, ending up
> with:
> 
> .../build/glibc/setjmp/test-as-const-jmp_buf-ssp.c:1:2: error: expected « = », « , », « ; », « asm » or « __attribute__ » at end of input
>     1 |  asconst_
>       |  ^~~~~~~~

That said, it's not enough, gen_test() does not emit a main() function,
and thus the test build fails with missing reference to main(). Is there
a strong reason for making the emission of code lazy with the started
boolean?

Samuel
  
Joseph Myers Dec. 3, 2018, 1:23 p.m. UTC | #2
On Sat, 1 Dec 2018, Samuel Thibault wrote:

> 2018-12-01  Samuel Thibault  <samuel.thibault@ens-lyon.org>
> 
> 	* scripts/gen-as-const.py (main): Avoid emitting empty line when
> 	there is no element in `consts'.

OK, please commit.
  
Samuel Thibault Dec. 3, 2018, 1:42 p.m. UTC | #3
Joseph Myers, le lun. 03 déc. 2018 13:23:48 +0000, a ecrit:
> On Sat, 1 Dec 2018, Samuel Thibault wrote:
> 
> > 2018-12-01  Samuel Thibault  <samuel.thibault@ens-lyon.org>
> > 
> > 	* scripts/gen-as-const.py (main): Avoid emitting empty line when
> > 	there is no element in `consts'.
> 
> OK, please commit.

Done so, thanks.

Samuel
  
H.J. Lu Dec. 3, 2018, 4:17 p.m. UTC | #4
On Mon, Dec 3, 2018 at 5:42 AM Samuel Thibault <samuel.thibault@gnu.org> wrote:
>
> Joseph Myers, le lun. 03 déc. 2018 13:23:48 +0000, a ecrit:
> > On Sat, 1 Dec 2018, Samuel Thibault wrote:
> >
> > > 2018-12-01  Samuel Thibault  <samuel.thibault@ens-lyon.org>
> > >
> > >     * scripts/gen-as-const.py (main): Avoid emitting empty line when
> > >     there is no element in `consts'.
> >
> > OK, please commit.
>
> Done so, thanks.

I still got

/export/ssd/build/tools-build/glibc-many/src/glibc/csu/../sysdeps/i386/start.S:122:
undefined reference to `main'
collect2: error: ld returned 1 exit status
make[4]: *** [../Rules:201:
/export/ssd/build/tools-build/glibc-many/build/glibcs/i686-gnu/glibc/setjmp/test-as-const-jmp_buf-ssp]
Error 1
make[4]: *** Waiting for unfinished jobs....
rm /export/ssd/build/tools-build/glibc-many/build/glibcs/i686-gnu/glibc/setjmp/test-as-const-jmp_buf-ssp.c
make[4]: Leaving directory
'/export/ssd/build/tools-build/glibc-many/src/glibc/setjmp'
make[3]: *** [Makefile:258: setjmp/tests] Error 2
make[3]: Leaving directory '/export/ssd/build/tools-build/glibc-many/src/glibc'
make[2]: *** [Makefile:9: check] Error 2
make[2]: Leaving directory
'/export/ssd/build/tools-build/glibc-many/build/glibcs/i686-gnu/glibc'

FAIL: glibcs-i686-gnu check
  
Samuel Thibault Dec. 3, 2018, 4:29 p.m. UTC | #5
H.J. Lu, le lun. 03 déc. 2018 08:17:23 -0800, a ecrit:
> On Mon, Dec 3, 2018 at 5:42 AM Samuel Thibault <samuel.thibault@gnu.org> wrote:
> >
> > Joseph Myers, le lun. 03 déc. 2018 13:23:48 +0000, a ecrit:
> > > On Sat, 1 Dec 2018, Samuel Thibault wrote:
> > >
> > > > 2018-12-01  Samuel Thibault  <samuel.thibault@ens-lyon.org>
> > > >
> > > >     * scripts/gen-as-const.py (main): Avoid emitting empty line when
> > > >     there is no element in `consts'.
> > >
> > > OK, please commit.
> >
> > Done so, thanks.
> 
> I still got
> 
> /export/ssd/build/tools-build/glibc-many/src/glibc/csu/../sysdeps/i386/start.S:122:
> undefined reference to `main'

Yes, see my second mail in the same thread:

“
That said, it's not enough, gen_test() does not emit a main() function,
and thus the test build fails with missing reference to main(). Is there
a strong reason for making the emission of code lazy with the started
boolean?
”

which needs to be discussed too.

Samuel
  

Patch

diff --git a/scripts/gen-as-const.py b/scripts/gen-as-const.py
index b7a5744bb1..cabf401ed1 100644
--- a/scripts/gen-as-const.py
+++ b/scripts/gen-as-const.py
@@ -153,7 +153,7 @@  def main():
         print(gen_test(sym_data))
     else:
         consts = compute_c_consts(sym_data, args.cc)
-        print('\n'.join('#define %s %s' % c for c in sorted(consts.items())))
+        print(''.join('#define %s %s\n' % c for c in sorted(consts.items())), end='')
 
 if __name__ == '__main__':
     main()