On Sat, Mar 20, 2010 at 5:40 PM, Tadashi Koike <tadash...@gmail.com> wrote:
> Hi all,
>    (* I am weak in English, so pleas forgive my English mistake.)
>
>   Please teach me about a behavior of -save-temps=obj option
> on gcc 4.5. A behavior I found is whether bug or specification ?
>
> [ summary ]
>     compiling is failed when more than two source file are
>    specified with both -save-temps=obj and -o options.
>
> 1) Environment
>   -------------------------------------------------------
>   [System]: Fedora release 12 (Constantine)
>   [gcc version]:
>     % /usr/local/bin/gcc -v
>     Using built-in specs.
>     COLLECT_GCC=/usr/local/bin/gcc
>     
> COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper
>     Target: x86_64-unknown-linux-gnu
>     Configured with: ../gcc-4.5-20100304-src/configure
> --prefix=/usr/local --mandir=/usr/local/share/man
> --infodir=/usr/local/share/info --enable-languages=c,c++ --disable-nls
>     Thread model: posix
>     gcc version 4.5.0 20100304 (experimental) (GCC)
>   -------------------------------------------------------
>
> 2) Source files I used are bellow:
>   [main.c]
>   +------------------------------------------------------
>   |extern int func(const char *);
>   |int main () {
>   |  func("hello world!\n");
>   |}
>   +------------------------------------------------------
>   [func.c]
>   +------------------------------------------------------
>   |#include <stdio.h>
>   |int func (const char *str) {
>   |  return(fprintf(stdout, str));
>   |}
>   +------------------------------------------------------
>
> 3) Files/Directory structure is bellow:
>     /tmp/test/hellow.c
>              /func.c
>              /obj_dir/
>
> 4) Test operations.
>   I tryed bellow operations at /tmp/test directory.
>   -------------------------------------------------------
>   [[ operations being successful ]]
>     % gcc main.c func.c
>     % gcc -o obj_dir/hello main.c func.c
>     % gcc -save-temps=cwd main.c func.c
>     % gcc -save-temps=cwd -o obj_dir/hello main.c func.c
>     % gcc -save-temps=obj main.c func.c
>
>  [[ operations being error ]]
>     % gcc -save-temps=obj -o hellow main.c func.c
>     % gcc -save-temps=obj -o obj_dir/hellow main.c func.c
>
>     // example error messages //
>     obj_dir/hello.o: In function `func':
>     func.c:(.text+0x0): multiple definition of `func'
>     obj_dir/hello.o:func.c:(.text+0x0): first defined here
>     /usr/lib/../lib64/crt1.o: In function `_start':
>     (.text+0x20): undefined reference to `main'
>     collect2: ld returned 1 exit status
>
>     // more information//
>     * in this error case, temporary files are nemed as
>       'hello.i' and that content is from 'func.c', but
>       contents of 'hello.s' is perhaps from 'main.c'.
>   -------------------------------------------------------
>
> I think that two understanding are possible.
>   A) this behavior is a specification like '-o' option with
>       using -c option.
>
>       [ operation example ]
>       % gcc -c -o obj_dir/hello.o main.c func.c
>       gcc: cannot specify -o with -c, -S or -E with multiple files
>
>   B) this behavior is a bug.
>       [ reason ]
>       In below case, temporary files are made in current
>       directory. names of these files are based on 'source
>       file'.
>
>       % gcc -save-temps=cwd -o obj_dir/hello main.c func.c
>
>       When -save-temps=cwd option is exchanged to
>       -save-temps=obj, I expect to keep names of temporary
>       files as from 'source file', and only a place to save
>       temporary files are exchanged to object directory.
>
> Because I don't understand that this behavior is whether
> bug or specification, so I don't report this to bugzilla
> yet.
>
> I feel that function of -save-temps=obj option is great!
> I would like to know how to use -save-temps=obj option.
> So pleas teach me true behavior about -save-temps=obj.

It should be an error to use -save-temps=obj with multiple
input files.  Mike, can you look at this?

Thanks,
Richard.

> Best regards,
> Tadashi Koike
>

Reply via email to