What is the purpose of “-Wa,option” in GCC? [close

2020-08-21 02:47发布

How do I use

-Wa,option

in GCC? What are all the options I can pass to the assembler? Is there a list of all GCC options?

For example, I found -Wa,-a,-ad here. What does it mean?

3条回答
劫难
2楼-- · 2020-08-21 03:02

In order to see a list of options of any command in bash, you can run the following command:

man COMMAND

In this case

man gcc

will reveal that -Wa,option means the following:

Pass option as an option to the assembler. If option contains commas, it is split into multiple options at the commas.

查看更多
走好不送
3楼-- · 2020-08-21 03:22

Since these options are passed to the assembler, you need to check the man page for as, not gcc.

-a turns on assembly output listings (which is written to standard output), while -ad omits any debugging directive from the output listing.

查看更多
一夜七次
4楼-- · 2020-08-21 03:26

Always check the Documentation

-Wa,option
Pass option as an option to the assembler. If option contains commas, it is split into multiple options at the commas.

So in your case -a and -ad were passed to the assembler, what those do depend on your assembler. Gcc doesn't know what to do with system-specific assembler options so giving it the -Wa flag lets it know to just pass whatever follows through.

You can also find the documentation locally via man pages. To open the documentation on GNU's assembler, perform:

$ man 1 as

It will open:

AS(1)                        GNU Development Tools                       AS(1)

NAME
       AS - the portable GNU assembler.

SYNOPSIS
       as [-a[cdghlns][=file]] [--alternate] [-D]
        [--compress-debug-sections]  [--nocompress-debug-sections]
        [--debug-prefix-map old=new]
        [--defsym sym=val] [-f] [-g] [--gstabs]
        [--gstabs+] [--gdwarf-2] [--gdwarf-sections]
        [--help] [-I dir] [-J]
        [-K] [-L] [--listing-lhs-width=NUM]
        [--listing-lhs-width2=NUM] [--listing-rhs-width=NUM]
        [--listing-cont-lines=NUM] [--keep-locals] [-o
        objfile] [-R] [--reduce-memory-overheads] [--statistics]
        [-v] [-version] [--version] [-W] [--warn]
        [--fatal-warnings] [-w] [-x] [-Z] [@FILE]
        [--size-check=[error|warning]]
        [--target-help] [target-options]
        [--|files ...]
        ...
查看更多
登录 后发表回答