All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [ERROR] perf build failure on current tip:perf/core
Date: Sun, 08 Jan 2012 21:30:58 +0900	[thread overview]
Message-ID: <87r4zaz88t.fsf@gmail.com> (raw)
In-Reply-To: <20120108113426.GB26516@elte.hu> (Ingo Molnar's message of "Sun, 8 Jan 2012 12:34:27 +0100")

Ingo Molnar <mingo@elte.hu> wrote:

> * Namhyung Kim <namhyung@gmail.com> wrote:
>
>> 2012-01-08 (일), 10:00 +0100, Ingo Molnar:
>> > * Namhyung Kim <namhyung@gmail.com> wrote:
>> > 
>> > > Hi,
>> > > 
>> > > When I tried to build perf, I was faced with following error:
>> > > 
>> > >     CC util/trace-event-info.o
>> > > cc1: warnings being treated as errors
>> > > util/trace-event-info.c: In function ‘record_file’:
>> > > util/trace-event-info.c:192: error: implicit declaration of function
>> > > ‘pwrite’
>> > > util/trace-event-info.c:192: error: nested extern declaration of
>> > > ‘pwrite’
>> > > make: *** [util/trace-event-info.o] Error 1
>> > > 
>> > > The code I tried was latest tip:perf/core - 9e183426bfb5 ("perf kvm: Fix
>> > > copy & paste error in description") and code in mainline (v3.2) doesn't
>> > > have this problem. Looking at the code, I couldn't find any clue to
>> > > this. Any idea?
>> > > 
>> > > FYI, my system is Ubuntu 10.04 on x86_64. gcc version is 4.4.3:
>> > 
>> > Which header does pwrite() belong to on that system - what does 
>> > 'map pwrite' say? It ought to be unistd.h, which is directly 
>> > included in util/trace-event-info.c.
>> > 
>> > My guess is that it might be related to:
>> > 
>> > tools/perf/Makefile:ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
>> > 
>> > Which introduces pwrite64() and defines pwrite() to them.
>> > 
>> > Does the patch below help? It's only a workaround really as 
>> > pwrite() ought to exist ... Also, i have only tested this on 
>> > 64-bit.
>> > 
>> > Thanks,
>> > 
>> > 	Ingo
>> > 
>> > diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
>> > index ac6830d..ba8b024 100644
>> > --- a/tools/perf/util/trace-event-info.c
>> > +++ b/tools/perf/util/trace-event-info.c
>> > @@ -189,7 +189,7 @@ static void record_file(const char *file, size_t hdr_sz)
>> >  	if (bigendian())
>> >  		sizep += sizeof(u64) - hdr_sz;
>> >  
>> > -	if (hdr_sz && pwrite(output_fd, sizep, hdr_sz, hdr_pos) < 0)
>> > +	if (hdr_sz && pwrite64(output_fd, sizep, hdr_sz, hdr_pos) < 0)
>> >  		die("writing to %s", output_file);
>> >  }
>> >  
>> 
>> Hello,
>> 
>> Unfortunately, above patch doesn't work for my system:
>> 
>>       CC util/trace-event-info.o
>>   cc1: warnings being treated as errors
>>   util/trace-event-info.c: In function ‘record_file’:
>>   util/trace-event-info.c:192: error: implicit declaration of function
>> ‘pwrite64’
>>   util/trace-event-info.c:192: error: nested extern declaration of
>> ‘pwrite64’
>> 
>> And 'map pwrite' on terminal says:
>
> 'man pwrite' i wanted to say.

Ah, OK :) here it is.

PREAD(2)                  Linux Programmer's Manual                     PREAD(2)

NAME
       pread, pwrite - read from or write to a file descriptor at a given offset

SYNOPSIS
       #define _XOPEN_SOURCE 500

       #include <unistd.h>

       ssize_t pread(int fd, void *buf, size_t count, off_t offset);

       ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
...

And #defining _XOPEN_SOURCE to 500 before the #include doesn't resolve the issue.


>
>>   $ map pwrite
>>   The program 'map' is currently not installed.  You can install it by
>> typing:
>>   sudo apt-get install sgt-puzzles
>> 
>> I don't think this is the package what you said. Anyway quick grep'ing
>> pwrite tells me it's in the unistd.h:
>> 
>>   $ grep pwrite /usr/include/unistd.h
>>   extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n,
>>   extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf,
>> 			     pwrite64) __wur;
>>   #   define pwrite pwrite64
>
> There's multiple definitions there, and we get lost somehow - as 
> unistd.h is included:
>
>   ~/tip/tools/perf> grep -n unistd.h util/trace-event-info.c
>   34:#include <unistd.h>
>
> Thanks,
>
> 	Ingo

This is the content of my /usr/include/unistd.h:

#ifdef __USE_UNIX98
# ifndef __USE_FILE_OFFSET64
extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
		      __off_t __offset) __wur;
extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n,
		       __off_t __offset) __wur;
# else
#  ifdef __REDIRECT
extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes,
				   __off64_t __offset),
			   pread64) __wur;
extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf,
				    size_t __nbytes, __off64_t __offset),
			   pwrite64) __wur;
#  else
#   define pread pread64
#   define pwrite pwrite64
#  endif
# endif

# ifdef __USE_LARGEFILE64
extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
			__off64_t __offset) __wur;
extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
			 __off64_t __offset) __wur;
# endif
#endif

I think all of pread/write functions are properly defined here:

  $ echo '#include <unistd.h>' | \
  > gcc -xc -E -dM -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 - | \
  > grep -e UNIX98 -e LARGEFILE64 -e FILE_OFFSET
  #define __ILP32_OFFBIG_CFLAGS "-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
  #define _LARGEFILE64_SOURCE 1
  #define __USE_UNIX98 1
  #define __USE_LARGEFILE64 1
  #define _FILE_OFFSET_BITS 64
  #define __USE_FILE_OFFSET64 1

Thanks,
Namhyung


  reply	other threads:[~2012-01-08 12:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-07 15:42 [ERROR] perf build failure on current tip:perf/core Namhyung Kim
2012-01-07 17:35 ` Arnaldo Carvalho de Melo
2012-01-08  9:00 ` Ingo Molnar
2012-01-08  9:41   ` Namhyung Kim
2012-01-08 11:34     ` Ingo Molnar
2012-01-08 12:30       ` Namhyung Kim [this message]
2012-01-08 14:03         ` Ingo Molnar
2012-01-08 14:50           ` Namhyung Kim
2012-01-08 15:00             ` Ingo Molnar
2012-01-08 15:10               ` [PATCH] perf tools: Fix compile error on x86_64 Ubuntu Namhyung Kim
2012-01-08 15:12                 ` Arnaldo Carvalho de Melo
2012-01-08 15:32                   ` Ingo Molnar
2012-01-08 15:49                     ` Namhyung Kim
2012-01-09  7:29                 ` [tip:perf/core] " tip-bot for Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r4zaz88t.fsf@gmail.com \
    --to=namhyung@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.