Bug 25572 - /dev/null should be excluded from 'files are the same' check
Summary: /dev/null should be excluded from 'files are the same' check
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-18 05:36 UTC by Masahiro Yamada
Modified: 2020-03-06 10:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-03-02 00:00:00


Attachments
Proposed patch (449 bytes, patch)
2020-03-02 17:50 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Masahiro Yamada 2020-02-18 05:36:35 UTC
Hi.

I think using /dev/null for both input and output
is useful, but the assembler emits this warning:

$ gcc -c -x assembler /dev/null -o /dev/null
Assembler messages:
Fatal error: The input '/dev/null' and output '/dev/null' files are the same


This is especially useful to check whether
a particular flag is supported or not.

$ gcc -Wa,<some-assembler-flag> -c -x assembler /dev/null -o /dev/null

   or

$ as <some-assembler-flag> /dev/null -o /dev/null

Then, check the exit code.

This technique is widely used in the Linux kernel build system.


However, with the current binutils,
this always exits with 1 with the 'files are the same' warning.

We could work around it by using /dev/zero
as a data sink, but this looks a bit strange.

$ gcc -Wa,<some-assembler-flag> -c -x assembler /dev/null -o /dev/zero


This was reported here
https://patchwork.kernel.org/patch/11347227/

I think device files should be excluded from the
same-file check.
Comment 1 Nick Clifton 2020-03-02 17:50:31 UTC
Created attachment 12333 [details]
Proposed patch

Hi Masahiro,

  Would a patch like this work for you ?

Cheers
  Nick
Comment 2 Alan Modra 2020-03-05 04:57:20 UTC
Looks good to me.
Comment 3 Masahiro Yamada 2020-03-06 04:29:43 UTC
Hi Nick,

Worked for me.

Tested-by: Masahiro Yamada <masahiroy@kernel.org>
Comment 4 Sourceware Commits 2020-03-06 10:45:39 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3c968de5c7d1719b2f9b538f2f7f5f5922e5f311

commit 3c968de5c7d1719b2f9b538f2f7f5f5922e5f311
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Mar 6 10:44:12 2020 +0000

    Stop the assembler from complaining that the input and output files are the same, if neither of them are regular files.
    
    	PR 25572
    	* as.c (main): Allow matching input and outputs when they are
    	not regular files.
Comment 5 Nick Clifton 2020-03-06 10:46:40 UTC
Patch applied.