Opened 16 years ago

Closed 16 years ago

#3481 closed bug (fixed)

libio.h troubles on gcc4 Haiku

Reported by: scottmc Owned by: stippi
Priority: normal Milestone: R1
Component: - General Version: R1/pre-alpha1
Keywords: Cc: planche2k@…, eric.petit@…
Blocked By: Blocking:
Platform: All

Description

As posted on the HaikuPorts dev mailing list by Blub: http://lists.ports.haiku-files.org/pipermail/haikuports-devs-ports.haiku-files.org/2009-February/000262.html

It seems that the libio.h header has some flaws, in gnutls (which atm fails installing for me due to failing texi-references, so I'll try with gtk-doc support) and in expat I ran into some problems with _IO_{putc,peekc,getc}_unlocked defined multiple times, I then copied /boot/develop/headers/posix/libio.h into ./lib/, and made those functions static since they were inlined anyway.

If there's some other fix for that let me know please, if not, have a look at those files:

Attachments (3)

libio_h.diff (1.0 KB ) - added by scottmc 16 years ago.
Blub's suggested patch
stdio.h.diff (766 bytes ) - added by stippi 16 years ago.
Alternative stdio.h patch that keeps the semantics.
libio.patch (2.7 KB ) - added by zooey 16 years ago.
libio-patch suggested by kaliber

Download all attachments as: .zip

Change History (20)

by scottmc, 16 years ago

Attachment: libio_h.diff added

Blub's suggested patch

comment:1 by andreasf, 16 years ago

Cc: planche2k@… added

comment:2 by andreasf, 16 years ago

If we define them as static, we can drop the initial definitions.

expat is still happy then.

comment:3 by titer, 16 years ago

Cc: eric.petit@… added

#3537 "gcc4 issues with extern inlines and -std=gnu99" is a duplicate of this issue.

Grepping /boot/develop/headers for extern inlines, it seems libio.h would be the only file that requires patching.

comment:4 by stippi, 16 years ago

Owner: changed from axeld to stippi
Status: newassigned

by stippi, 16 years ago

Attachment: stdio.h.diff added

Alternative stdio.h patch that keeps the semantics.

comment:5 by stippi, 16 years ago

Thanks to the references given in #3537, I came up with the above patch. The difference is that the behaviour is maintained when compiling with -std99 or -gnu99. Could you please apply this and tell me if that solves the issues? Thanks!

in reply to:  5 comment:6 by titer, 16 years ago

I do not believe we need to maintain the behavior: none of Haiku's code overrides the _IO_{putc,peekc,getc}_unlocked functions, and no code should ever assume they can be (look at Linux's libio.h, it just #defines them as macros).

I'm for simplicity, so making them static inlines regardless of what we are building (c89/c99/c++) would be my choice :)

comment:7 by stippi, 16 years ago

Resolution: fixed
Status: assignedclosed

Ok, I commited a simplified version of blub's patch in hrev29471. Thanks for the feedback.

comment:9 by bonefish, 16 years ago

Resolution: fixed
Status: closedreopened

Reverted hrev29471 in hrev29547 as it breaks building kernel code in debug mode with gcc 2.95.3. Code for the static inline functions is generated and the referenced functions (underflow(),...) don't exist in the kernel.

comment:10 by stippi, 16 years ago

Ingo, can you please check with hrev29558? I committed my original patch which should only fix the actual problem without changing any semantics.

in reply to:  10 comment:11 by bonefish, 16 years ago

Replying to stippi:

Ingo, can you please check with hrev29558? I committed my original patch which should only fix the actual problem without changing any semantics.

gcc 2.95.3 debug builds work fine with this solution.

comment:12 by stippi, 16 years ago

Resolution: fixed
Status: reopenedclosed

Thanks. I consider it fixed then.

comment:13 by andreasf, 16 years ago

Resolution: fixed
Status: closedreopened

Nope, still with us: Building expat with gcc 4.3 continues to complain about multiple definitions of the functions.

The following workaround fixes the expat build for me:

  1. Comment out the initial declarations of the three affected functions.
  2. After the __INLINE wizardry, simply define __INLINE to static inline.

Could it be that this error is caused by the GCC 4.3 special handling section in libio.h? No special options for c99 or gnu99 are being passed afaict.

comment:14 by kaliber, 16 years ago

If you want you can extract a correct patch for libio.h from TiltOS' patch http://svn.gna.org/viewcvs/pingwinek/trunk/projects/tiltos/tiltos.patch It is based on a newer code from glibc.

by zooey, 16 years ago

Attachment: libio.patch added

libio-patch suggested by kaliber

comment:15 by zooey, 16 years ago

Extracted kaliber's suggested patch from TiltOS and attached it here, as libio.patch.

The resulting libio.h at least allows to compile rsync on gcc4, which failed before, too. The patch requires testing with gcc2, though.

comment:16 by scottmc, 16 years ago

patch seems to work on gcc2 as well, at least I was able to build expat cvs head with the patched libio.h in place.

comment:17 by zooey, 16 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in hrev30861

Note: See TracTickets for help on using tickets.