Opened 10 years ago

Closed 10 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:
Has a Patch: no 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 10 years ago.
Blub's suggested patch
stdio.h.diff (766 bytes) - added by stippi 10 years ago.
Alternative stdio.h patch that keeps the semantics.
libio.patch (2.7 KB) - added by zooey 10 years ago.
libio-patch suggested by kaliber

Download all attachments as: .zip

Change History (20)

Changed 10 years ago by scottmc

Attachment: libio_h.diff added

Blub's suggested patch

comment:1 Changed 10 years ago by andreasf

Cc: planche2k@… added

comment:2 Changed 10 years ago by andreasf

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

expat is still happy then.

comment:3 Changed 10 years ago by titer

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 Changed 10 years ago by stippi

Owner: changed from axeld to stippi
Status: newassigned

Changed 10 years ago by stippi

Attachment: stdio.h.diff added

Alternative stdio.h patch that keeps the semantics.

comment:5 Changed 10 years ago by stippi

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!

comment:6 in reply to:  5 Changed 10 years ago by titer

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 Changed 10 years ago by stippi

Resolution: fixed
Status: assignedclosed

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

comment:9 Changed 10 years ago by bonefish

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 Changed 10 years ago by stippi

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

comment:11 in reply to:  10 Changed 10 years ago by bonefish

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 Changed 10 years ago by stippi

Resolution: fixed
Status: reopenedclosed

Thanks. I consider it fixed then.

comment:13 Changed 10 years ago by andreasf

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 Changed 10 years ago by kaliber

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.

Changed 10 years ago by zooey

Attachment: libio.patch added

libio-patch suggested by kaliber

comment:15 Changed 10 years ago by zooey

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 Changed 10 years ago by scottmc

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 Changed 10 years ago by zooey

Resolution: fixed
Status: reopenedclosed

Fixed in hrev30861

Note: See TracTickets for help on using tickets.