Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 574610 - app-misc/fdupes-1.51 fails to compile on musl
Summary: app-misc/fdupes-1.51 fails to compile on musl
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Shell Tools Herd Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: musl-porting
  Show dependency tree
 
Reported: 2016-02-13 08:50 UTC by Michael Jones
Modified: 2016-02-29 07:48 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Jones 2016-02-13 08:50:01 UTC
Probably should be linked to https://bugs.gentoo.org/show_bug.cgi?id=430702


 * Package:    app-misc/fdupes-1.51
 * Repository: gentoo
 * Maintainer: shell-tools@gentoo.org
 * USE:        arm elibc_musl kernel_linux userland_GNU
 * FEATURES:   preserve-libs sandbox userpriv usersandbox
>>> Unpacking source...
>>> Unpacking fdupes-1.51.tar.gz to /var/tmp/portage/app-misc/fdupes-1.51/work
>>> Source unpacked in /var/tmp/portage/app-misc/fdupes-1.51/work
>>> Preparing source in /var/tmp/portage/app-misc/fdupes-1.51/work/fdupes-1.51 ...
 * Applying fdupes-1.51-makefile.patch ...
 [ ok ]
 * Applying fdupes-1.50_pre2-compare-file.patch ...
 [ ok ]
 * Applying fdupes-1.50_pre2-typo.patch ...
 [ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/app-misc/fdupes-1.51/work/fdupes-1.51 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/app-misc/fdupes-1.51/work/fdupes-1.51 ...
make -j30 CC=armv7a-hardfloat-linux-musleabi-gcc
armv7a-hardfloat-linux-musleabi-gcc -O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -Wall -I. -DVERSION=\"1.51\"   -D_FILE_OFFSET_BITS=64  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -c -o fdupes.o fdupes.c
armv7a-hardfloat-linux-musleabi-gcc -O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -Wall -I. -DVERSION=\"1.51\"   -D_FILE_OFFSET_BITS=64  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE  -c -o md5/md5.o md5/md5.c
fdupes.c: In function ‘main’:
fdupes.c:1172:13: error: assignment of read-only variable ‘stdin’
       stdin = freopen("/dev/tty", "r", stdin);
             ^
<builtin>: recipe for target 'fdupes.o' failed
make: *** [fdupes.o] Error 1
make: *** Waiting for unfinished jobs....
 * ERROR: app-misc/fdupes-1.51::gentoo failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=app-misc/fdupes-1.51::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=app-misc/fdupes-1.51::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/app-misc/fdupes-1.51/temp/build.log.gz'.
 * The ebuild environment file is located at '/var/tmp/portage/app-misc/fdupes-1.51/temp/environment'.
 * Working directory: '/var/tmp/portage/app-misc/fdupes-1.51/work/fdupes-1.51'
 * S: '/var/tmp/portage/app-misc/fdupes-1.51/work/fdupes-1.51'
Comment 1 Anthony Basile gentoo-dev 2016-02-18 11:33:50 UTC
(In reply to Michael Jones from comment #0)

> fdupes.c: In function ‘main’:
> fdupes.c:1172:13: error: assignment of read-only variable ‘stdin’
>        stdin = freopen("/dev/tty", "r", stdin);
>              ^

I'm going to ask Rich about this one, or look directly at the POSIX standards because musl intentionally makes stdin read-only.  I don't understand why some programs do this instead of using dup2() or similar.
Comment 2 Anthony Basile gentoo-dev 2016-02-18 11:47:10 UTC
(In reply to Anthony Basile from comment #1)
> (In reply to Michael Jones from comment #0)
> 
> > fdupes.c: In function ‘main’:
> > fdupes.c:1172:13: error: assignment of read-only variable ‘stdin’
> >        stdin = freopen("/dev/tty", "r", stdin);
> >              ^
> 
> I'm going to ask Rich about this one, or look directly at the POSIX
> standards because musl intentionally makes stdin read-only.  I don't
> understand why some programs do this instead of using dup2() or similar.

Actually it should be as easy as just dropping `stdin =`.  This at least works for stdout as in this little program:

#include <stdio.h>

int main() {
	freopen("zzz.txt", "w", stdout);
	printf("hi\n");
}

So I'm not sure why people do stdin = freopen(..);
Comment 3 Rich Felker 2016-02-18 16:04:41 UTC
It's not POSIX related, just plain C. stdin is specified as a macro that expands to an expression (think rvalue) of type FILE *. It need not even be an lvalue, much less one for which assignment is possible.

Indeed just dropping the assignment is fine too. freopen only has two possible return values. On success it returns the same FILE * you passed into it. On failure it returns 0 (and the FILE * you passed in has been closed, so there's no way to recover and you probably need to exit immediately).
Comment 4 Anthony Basile gentoo-dev 2016-02-28 20:08:50 UTC
Its in the overlay, I'm going to see about getting a patch upstream.
Comment 5 Anthony Basile gentoo-dev 2016-02-28 20:16:25 UTC
Actually Felix already got a patch upstream

https://github.com/adrianlopezroche/fdupes/commit/fe2d8334bfa28ff05fa1a2ffe8555a19b41be0ea

but its a bit stale with

https://github.com/adrianlopezroche/fdupes/commit/03abad92b65b3d7174349ae2cbd08177afec1b79

Both of those patches nail the issue correctly.


@darkside, heroxbd, jlec, monsieurp, zlg is it okay if I back port those two patches?
Comment 6 Patrice Clement gentoo-dev 2016-02-28 22:44:51 UTC
Sure, go ahead!
Comment 7 zlg (RETIRED) gentoo-dev 2016-02-29 01:24:19 UTC
Looks good to me.
Comment 8 Anthony Basile gentoo-dev 2016-02-29 07:48:26 UTC
done