天天看點

跟老韓學Ubuntu Server 2204-gcc指令幫助手冊07節

作者:老韓Linux菌

GCC是每個從事Linux,以及嵌入式開發等必備的編譯器,由于幫助手冊較多,這裡使用了分頁的形式進行分享,如下為Ubuntu Server 22.04作業系統平台和GCC編譯器的基本資訊。

跟老韓學Ubuntu Server 2204-gcc指令幫助手冊07節
跟老韓學Ubuntu Server 2204-gcc指令幫助手冊07節

GCC幫助手冊的第7小節,第1247~1447行。

1247              Version 14, which first appeared in G++ 10, corrects the mangling of the nullptr expression.
1248              Version 15, which first appeared in G++ 11, changes the mangling of "__alignof__" to be distinct from that
1249              of "alignof", and dependent operator names.
1250              See also -Wabi.
1251          -fabi-compat-version=n
1252              On targets that support strong aliases, G++ works around mangling changes by creating an alias with the
1253              correct mangled name when defining a symbol with an incorrect mangled name.  This switch specifies which
1254              ABI version to use for the alias.
1255              With -fabi-version=0 (the default), this defaults to 11 (GCC 7 compatibility).  If another ABI version is
1256              explicitly selected, this defaults to 0.  For compatibility with GCC versions 3.2 through 4.9, use
1257              -fabi-compat-version=2.
1258              If this option is not provided but -Wabi=n is, that version is used for compatibility aliases.  If this
1259              option is provided along with -Wabi (without the version), the version from this option is used for the
1260              warning.
1261          -fno-access-control
1262              Turn off all access checking.  This switch is mainly useful for working around bugs in the access control
1263              code.
1264          -faligned-new
1265              Enable support for C++17 "new" of types that require more alignment than "void* ::operator
1266              new(std::size_t)" provides.  A numeric argument such as "-faligned-new=32" can be used to specify how much
1267              alignment (in bytes) is provided by that function, but few users will need to override the default of
1268              "alignof(std::max_align_t)".
1269              This flag is enabled by default for -std=c++17.
1270          -fchar8_t
1271          -fno-char8_t
1272              Enable support for "char8_t" as adopted for C++20.  This includes the addition of a new "char8_t"
1273              fundamental type, changes to the types of UTF-8 string and character literals, new signatures for user-
1274              defined literals, associated standard library updates, and new "__cpp_char8_t" and "__cpp_lib_char8_t"
1275              feature test macros.
1276              This option enables functions to be overloaded for ordinary and UTF-8 strings:
1277                      int f(const char *);    // #1
1278                      int f(const char8_t *); // #2
1279                      int v1 = f("text");     // Calls #1
1280                      int v2 = f(u8"text");   // Calls #2
1281              and introduces new signatures for user-defined literals:
1282                      int operator""_udl1(char8_t);
1283                      int v3 = u8'x'_udl1;
1284                      int operator""_udl2(const char8_t*, std::size_t);
1285                      int v4 = u8"text"_udl2;
1286                      template<typename T, T...> int operator""_udl3();
1287                      int v5 = u8"text"_udl3;
1288              The change to the types of UTF-8 string and character literals introduces incompatibilities with ISO C++11
1289              and later standards.  For example, the following code is well-formed under ISO C++11, but is ill-formed
1290              when -fchar8_t is specified.
1291                      char ca[] = u8"xx";     // error: char-array initialized from wide
1292                                              //        string
1293                      const char *cp = u8"xx";// error: invalid conversion from
1294                                              //        `const char8_t*' to `const char*'
1295                      int f(const char*);
1296                      auto v = f(u8"xx");     // error: invalid conversion from
1297                                              //        `const char8_t*' to `const char*'
1298                      std::string s{u8"xx"};  // error: no matching function for call to
1299                                              //        `std::basic_string<char>::basic_string()'
1300                      using namespace std::literals;
1301                      s = u8"xx"s;            // error: conversion from
1302                                              //        `basic_string<char8_t>' to non-scalar
1303                                              //        type `basic_string<char>' requested
1304          -fcheck-new
1305              Check that the pointer returned by "operator new" is non-null before attempting to modify the storage
1306              allocated.  This check is normally unnecessary because the C++ standard specifies that "operator new" only
1307              returns 0 if it is declared "throw()", in which case the compiler always checks the return value even
1308              without this option.  In all other cases, when "operator new" has a non-empty exception specification,
1309              memory exhaustion is signalled by throwing "std::bad_alloc".  See also new (nothrow).
1310          -fconcepts
1311          -fconcepts-ts
1312              Below -std=c++20, -fconcepts enables support for the C++ Extensions for Concepts Technical Specification,
1313              ISO 19217 (2015).
1314              With -std=c++20 and above, Concepts are part of the language standard, so -fconcepts defaults to on.  But
1315              the standard specification of Concepts differs significantly from the TS, so some constructs that were
1316              allowed in the TS but didn't make it into the standard can still be enabled by -fconcepts-ts.
1317          -fconstexpr-depth=n
1318              Set the maximum nested evaluation depth for C++11 constexpr functions to n.  A limit is needed to detect
1319              endless recursion during constant expression evaluation.  The minimum specified by the standard is 512.
1320          -fconstexpr-cache-depth=n
1321              Set the maximum level of nested evaluation depth for C++11 constexpr functions that will be cached to n.
1322              This is a heuristic that trades off compilation speed (when the cache avoids repeated calculations) against
1323              memory consumption (when the cache grows very large from highly recursive evaluations).  The default is 8.
1324              Very few users are likely to want to adjust it, but if your code does heavy constexpr calculations you
1325              might want to experiment to find which value works best for you.
1326          -fconstexpr-loop-limit=n
1327              Set the maximum number of iterations for a loop in C++14 constexpr functions to n.  A limit is needed to
1328              detect infinite loops during constant expression evaluation.  The default is 262144 (1<<18).
1329          -fconstexpr-ops-limit=n
1330              Set the maximum number of operations during a single constexpr evaluation.  Even when number of iterations
1331              of a single loop is limited with the above limit, if there are several nested loops and each of them has
1332              many iterations but still smaller than the above limit, or if in a body of some loop or even outside of a
1333              loop too many expressions need to be evaluated, the resulting constexpr evaluation might take too long.
1334              The default is 33554432 (1<<25).
1335          -fcoroutines
1336              Enable support for the C++ coroutines extension (experimental).
1337          -fno-elide-constructors
1338              The C++ standard allows an implementation to omit creating a temporary that is only used to initialize
1339              another object of the same type.  Specifying this option disables that optimization, and forces G++ to call
1340              the copy constructor in all cases.  This option also causes G++ to call trivial member functions which
1341              otherwise would be expanded inline.
1342              In C++17, the compiler is required to omit these temporaries, but this option still affects trivial member
1343              functions.
1344          -fno-enforce-eh-specs
1345              Don't generate code to check for violation of exception specifications at run time.  This option violates
1346              the C++ standard, but may be useful for reducing code size in production builds, much like defining
1347              "NDEBUG".  This does not give user code permission to throw exceptions in violation of the exception
1348              specifications; the compiler still optimizes based on the specifications, so throwing an unexpected
1349              exception results in undefined behavior at run time.
1350          -fextern-tls-init
1351          -fno-extern-tls-init
1352              The C++11 and OpenMP standards allow "thread_local" and "threadprivate" variables to have dynamic (runtime)
1353              initialization.  To support this, any use of such a variable goes through a wrapper function that performs
1354              any necessary initialization.  When the use and definition of the variable are in the same translation
1355              unit, this overhead can be optimized away, but when the use is in a different translation unit there is
1356              significant overhead even if the variable doesn't actually need dynamic initialization.  If the programmer
1357              can be sure that no use of the variable in a non-defining TU needs to trigger dynamic initialization
1358              (either because the variable is statically initialized, or a use of the variable in the defining TU will be
1359              executed before any uses in another TU), they can avoid this overhead with the -fno-extern-tls-init option.
1360              On targets that support symbol aliases, the default is -fextern-tls-init.  On targets that do not support
1361              symbol aliases, the default is -fno-extern-tls-init.
1362          -fno-gnu-keywords
1363              Do not recognize "typeof" as a keyword, so that code can use this word as an identifier.  You can use the
1364              keyword "__typeof__" instead.  This option is implied by the strict ISO C++ dialects: -ansi, -std=c++98,
1365              -std=c++11, etc.
1366          -fno-implicit-templates
1367              Never emit code for non-inline templates that are instantiated implicitly (i.e. by use); only emit code for
1368              explicit instantiations.  If you use this option, you must take care to structure your code to include all
1369              the necessary explicit instantiations to avoid getting undefined symbols at link time.
1370          -fno-implicit-inline-templates
1371              Don't emit code for implicit instantiations of inline templates, either.  The default is to handle inlines
1372              differently so that compiles with and without optimization need the same set of explicit instantiations.
1373          -fno-implement-inlines
1374              To save space, do not emit out-of-line copies of inline functions controlled by "#pragma implementation".
1375              This causes linker errors if these functions are not inlined everywhere they are called.
1376          -fmodules-ts
1377          -fno-modules-ts
1378              Enable support for C++20 modules   The -fno-modules-ts is usually not needed, as that is the default.  Even
1379              though this is a C++20 feature, it is not currently implicitly enabled by selecting that standard version.
1380          -fmodule-header
1381          -fmodule-header=user
1382          -fmodule-header=system
1383              Compile a header file to create an importable header unit.
1384          -fmodule-implicit-inline
1385              Member functions defined in their class definitions are not implicitly inline for modular code.  This is
1386              different to traditional C++ behavior, for good reasons.  However, it may result in a difficulty during
1387              code porting.  This option makes such function definitions implicitly inline.  It does however generate an
1388              ABI incompatibility, so you must use it everywhere or nowhere.  (Such definitions outside of a named module
1389              remain implicitly inline, regardless.)
1390          -fno-module-lazy
1391              Disable lazy module importing and module mapper creation.
1392          -fmodule-mapper=[hostname]:port[?ident]
1393          -fmodule-mapper=|program[?ident] args...
1394          -fmodule-mapper==socket[?ident]
1395          -fmodule-mapper=<>[inout][?ident]
1396          -fmodule-mapper=<in>out[?ident]
1397          -fmodule-mapper=file[?ident]
1398              An oracle to query for module name to filename mappings.  If unspecified the CXX_MODULE_MAPPER environment
1399              variable is used, and if that is unset, an in-process default is provided.
1400          -fmodule-only
1401              Only emit the Compiled Module Interface, inhibiting any object file.
1402          -fms-extensions
1403              Disable Wpedantic warnings about constructs used in MFC, such as implicit int and getting a pointer to
1404              member function via non-standard syntax.
1405          -fnew-inheriting-ctors
1406              Enable the P0136 adjustment to the semantics of C++11 constructor inheritance.  This is part of C++17 but
1407              also considered to be a Defect Report against C++11 and C++14.  This flag is enabled by default unless
1408              -fabi-version=10 or lower is specified.
1409          -fnew-ttp-matching
1410              Enable the P0522 resolution to Core issue 150, template template parameters and default arguments: this
1411              allows a template with default template arguments as an argument for a template template parameter with
1412              fewer template parameters.  This flag is enabled by default for -std=c++17.
1413          -fno-nonansi-builtins
1414              Disable built-in declarations of functions that are not mandated by ANSI/ISO C.  These include "ffs",
1415              "alloca", "_exit", "index", "bzero", "conjf", and other related functions.
1416          -fnothrow-opt
1417              Treat a "throw()" exception specification as if it were a "noexcept" specification to reduce or eliminate
1418              the text size overhead relative to a function with no exception specification.  If the function has local
1419              variables of types with non-trivial destructors, the exception specification actually makes the function
1420              smaller because the EH cleanups for those variables can be optimized away.  The semantic effect is that an
1421              exception thrown out of a function with such an exception specification results in a call to "terminate"
1422              rather than "unexpected".
1423          -fno-operator-names
1424              Do not treat the operator name keywords "and", "bitand", "bitor", "compl", "not", "or" and "xor" as
1425              synonyms as keywords.
1426          -fno-optional-diags
1427              Disable diagnostics that the standard says a compiler does not need to issue.  Currently, the only such
1428              diagnostic issued by G++ is the one for a name having multiple meanings within a class.
1429          -fpermissive
1430              Downgrade some diagnostics about nonconformant code from errors to warnings.  Thus, using -fpermissive
1431              allows some nonconforming code to compile.
1432          -fno-pretty-templates
1433              When an error message refers to a specialization of a function template, the compiler normally prints the
1434              signature of the template followed by the template arguments and any typedefs or typenames in the signature
1435              (e.g. "void f(T) [with T = int]" rather than "void f(int)") so that it's clear which template is involved.
1436              When an error message refers to a specialization of a class template, the compiler omits any template
1437              arguments that match the default template arguments for that template.  If either of these behaviors make
1438              it harder to understand the error message rather than easier, you can use -fno-pretty-templates to disable
1439              them.
1440          -fno-rtti
1441              Disable generation of information about every class with virtual functions for use by the C++ run-time type
1442              identification features ("dynamic_cast" and "typeid").  If you don't use those parts of the language, you
1443              can save some space by using this flag.  Note that exception handling uses the same information, but G++
1444              generates it as needed. The "dynamic_cast" operator can still be used for casts that do not require run-
1445              time type information, i.e. casts to "void *" or to unambiguous base classes.
1446              Mixing code compiled with -frtti with that compiled with -fno-rtti may not work.  For example, programs may
1447              fail to link if a class compiled with -fno-rtti is used as a base for a class compiled with -frtti.