Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re: [uClibc] perl-5.8.5: non-portable code causes build failure on uclibc #7566

Closed
p5pRT opened this issue Oct 28, 2004 · 9 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Oct 28, 2004

Migrated from rt.perl.org#32197 (status was 'resolved')

Searchable as RT32197$

@p5pRT
Copy link
Author

p5pRT commented Oct 28, 2004

From vda@port.imtp.ilyichevsk.odessa.ua

This part of perl source code caused build failure on uclibc.

perl-5.8.5/perlio.c​:

static int
PerlIOStdio_invalidate_fileno(pTHX_ FILE *f)
{
  /* XXX this could use PerlIO_canset_fileno() and
  * PerlIO_set_fileno() support from Configure
  */
# if defined(__GLIBC__)
  /* There may be a better way for GLIBC​:
  - libio.h defines a flag to not close() on cleanup
  */
  f->_fileno = -1;
  return 1;
# elif defined(__sun__)
....

This is a gross hack. Why do perl fiddle with C lib internals
which are meant to be opaque to the user?

It is used exactly in one place only​:

IV
PerlIOStdio_close(pTHX_ PerlIO *f)
{
  FILE *stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
  if (!stdio) {
  errno = EBADF;
  return -1;
  }
  else {
  ....
  if (invalidate) {
  /* For STD* handles don't close the stdio at all
  this is because we have shared the FILE * too
  */
  if (stdio == stdin) {
  /* Some stdios are buggy fflush-ing inputs */
  return 0;
  }
  else if (stdio == stdout || stdio == stderr) {
  return PerlIO_flush(f);
  }
  /* Tricky - must fclose(stdio) to free memory but not close(fd)
  Use Sarathy's trick from maint-5.6 to invalidate the
  fileno slot of the FILE *
  */
  result = PerlIO_flush(f);
  saveerr = errno;
  if (!(invalidate = PerlIOStdio_invalidate_fileno(aTHX_ stdio))) {
  dupfd = PerlLIO_dup(fd);
  }
  }
  ......
--
vda

@p5pRT
Copy link
Author

p5pRT commented Oct 28, 2004

From jcromie@divsol.com

Denis Vlasenko (via RT) wrote​:

# New Ticket Created by Denis Vlasenko
# Please include the string​: [perl #32189]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org​:80/rt3/Ticket/Display.html?id=32189 >

This part of perl source code caused build failure on uclibc.

perl-5.8.5/perlio.c​:

static int
PerlIOStdio_invalidate_fileno(pTHX_ FILE *f)
{
/* XXX this could use PerlIO_canset_fileno() and
* PerlIO_set_fileno() support from Configure
*/
# if defined(__GLIBC__)
/* There may be a better way for GLIBC​:
- libio.h defines a flag to not close() on cleanup
*/
f->_fileno = -1;
return 1;
# elif defined(__sun__)
....

This is a gross hack. Why do perl fiddle with C lib internals
which are meant to be opaque to the user?

for speed. You can disable it with a configure adjustment.
Heres what Ive got for 5.8.5 on linux.

$ perl -V​:.\*fast.\*
d_faststdio='undef';
usefaststdio='define';

Note that it was undef in config, and apparently overridden (its not a
hint-file entry in linux)

btw - ICBW. If so, im sure someone will correct me.

@p5pRT
Copy link
Author

p5pRT commented Oct 28, 2004

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 28, 2004

From mjn3@codepoet.org

On Thu, Oct 28, 2004 at 10​:42​:49AM +0300, Denis Vlasenko wrote​:

This part of perl source code caused build failure on uclibc.

perl-5.8.5/perlio.c​:

See http​://www.uclibc.org/lists/uclibc/2004-March/008512.html

Manuel

@p5pRT
Copy link
Author

p5pRT commented Oct 28, 2004

From vda@port.imtp.ilyichevsk.odessa.ua

On Thursday 28 October 2004 13​:14, Jim Cromie via RT wrote​:

Denis Vlasenko (via RT) wrote​:

# New Ticket Created by Denis Vlasenko
# Please include the string​: [perl #32189]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org​:80/rt3/Ticket/Display.html?id=32189 >

This part of perl source code caused build failure on uclibc.

perl-5.8.5/perlio.c​:

static int
PerlIOStdio_invalidate_fileno(pTHX_ FILE *f)
{
/* XXX this could use PerlIO_canset_fileno() and
* PerlIO_set_fileno() support from Configure
*/
# if defined(__GLIBC__)
/* There may be a better way for GLIBC​:
- libio.h defines a flag to not close() on cleanup
*/
f->_fileno = -1;
return 1;
# elif defined(__sun__)
....

This is a gross hack. Why do perl fiddle with C lib internals
which are meant to be opaque to the user?

for speed. You can disable it with a configure adjustment.
Heres what Ive got for 5.8.5 on linux.

$ perl -V​:.\*fast.\*
d_faststdio='undef';
usefaststdio='define';

In perl build dir​:

# cat config.sh | grep faststdio
d_faststdio='undef'
usefaststdio='undef'

but it seems this code to be still compiled. Don't know whether
it is linked in the final product...

btw - ICBW. If so, im sure someone will correct me.

What is ICBW?
--
vda

@p5pRT
Copy link
Author

p5pRT commented Nov 4, 2004

From @smpeters

[mjn3@​codepoet.org - Thu Oct 28 10​:45​:31 2004]​:

On Thu, Oct 28, 2004 at 10​:42​:49AM +0300, Denis Vlasenko wrote​:

This part of perl source code caused build failure on uclibc.

perl-5.8.5/perlio.c​:

See http​://www.uclibc.org/lists/uclibc/2004-March/008512.html

Manuel

Rather than have everyone track it down, here is the proposed patch from
that mailing list email.

Inline Patch
--- perl-5.8.2/perlio.c-dist	2003-12-03 14:30:24.000000000 -0700
+++ perl-5.8.2/perlio.c	2003-12-03 14:32:10.000000000 -0700
@@ -2824,7 +2824,15 @@
     /* XXX this could use PerlIO_canset_fileno() and
      * PerlIO_set_fileno() support from Configure
      */
-#  if defined(__GLIBC__)
+#  if defined(__UCLIBC__)
+    /* uClibc must come before glibc because it defines __GLIBC__ as
well. */ \+\# if defined\(\_\_MASK\_READING\) \+ f\->\_\_filedes = \-1; \+\# else \+ f\->filedes = \-1; \+\# endif \+ return 1; \+\# elif defined\(\_\_GLIBC\_\_\)   /\* There may be a better way for GLIBC​:   \- libio\.h defines a flag to not close\(\) on cleanup   \*/

@p5pRT
Copy link
Author

p5pRT commented Nov 4, 2004

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2005

From @smpeters

[stmpeters - Thu Nov 04 08​:09​:26 2004]​:

[mjn3@​codepoet.org - Thu Oct 28 10​:45​:31 2004]​:

On Thu, Oct 28, 2004 at 10​:42​:49AM +0300, Denis Vlasenko wrote​:

This part of perl source code caused build failure on uclibc.

perl-5.8.5/perlio.c​:

See http​://www.uclibc.org/lists/uclibc/2004-March/008512.html

Manuel

Rather than have everyone track it down, here is the proposed patch from
that mailing list email.

--- perl-5.8.2/perlio.c-dist 2003-12-03 14​:30​:24.000000000 -0700
+++ perl-5.8.2/perlio.c 2003-12-03 14​:32​:10.000000000 -0700
@​@​ -2824,7 +2824,15 @​@​
/* XXX this could use PerlIO_canset_fileno() and
* PerlIO_set_fileno() support from Configure
*/
-# if defined(__GLIBC__)
+# if defined(__UCLIBC__)
+ /* uClibc must come before glibc because it defines __GLIBC__ as
well. */
+# if defined(__MASK_READING)
+ f->__filedes = -1;
+# else
+ f->filedes = -1;
+# endif
+ return 1;
+# elif defined(__GLIBC__)
/* There may be a better way for GLIBC​:
- libio.h defines a flag to not close() on cleanup
*/

This was included with change #23732.

@p5pRT p5pRT closed this as completed Jun 23, 2005
@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2005

@smpeters - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant