nvc(1)

๐Ÿ“ฆ
version 26.9 ยท 3 versions
, in arch rolling

๐Ÿ’… nvc โ€” the NVIDIA ANSI and K&R C compiler ๐Ÿ’…

okay bestie, welcome to nvc(1) from the General Commands Manual ๐ŸŽ€ this is the compiler that makes your GPU go brrr, and we're gonna read the whole thing together. grab a strawberry drink ๐Ÿ“


โœจ NAME โœจ

nvc โ€” The NVIDIA ANSI and K&R C compiler. that's the whole name, she's iconic and she knows it ๐Ÿ‘‘


๐ŸŒธ SYNOPSIS ๐ŸŒธ

nvc [ -flag ]...  sourcefile...

literally just: some flags, then some source files. that's the whole vibe โœจ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so like, nvc is a C11 compiler for NVIDIA GPUs and AMD and Intel CPU โ€” yes she multitasks, main character energy fr ๐Ÿ’…

  • she supports C11 โœ…
  • she supports GPU parallel programming with OpenACC ๐Ÿ”ฅ
  • she supports multicore CPU programming with OpenACC and OpenMP ๐Ÿซถ

and the way she works is: nvc invokes the C compiler, assembler, and linker with options derived from its command line arguments. like she's the manager and they're the team, periodt.


๐ŸŽ€ source file suffixes (iykyk) ๐ŸŽ€

the suffix at the end of your source file name tells her what kind of processing to do, no cap:

  • .c โ€” C source; preprocess, compile
  • .i โ€” C source after preprocessing; compile
  • .s โ€” assembler source; assemble
  • .S โ€” assembler source; preprocess, assemble
  • .o โ€” object file; passed to linker
  • .a โ€” library archive file; passed to linker

โœจ bonus lore: if she's coinstalled with nvfortran, then Fortran file suffixes are also recognized and compiled with the nvfortran compilers โ€” see nvfortran and NVIDIA User's Guide. and anything else? other files are passed to the linker (if linking is requested) with a warning message ๐Ÿ™ˆ like she'll do it but she's judging you a little.


๐Ÿ’€ the intermediate files situation ๐Ÿ’€

listen close bestie, this part matters:

unless you override the default action using a command-line option, nvc deletes the intermediate preprocessor and assembler files โ€” see the options -c, -E, -P, and -Mkeepasm. and if a single C program is compiled and linked with one nvc command, the intermediate object file is also deleted ๐Ÿ—‘๏ธโœจ

Linking is the last stage of the compile process, unless you use one of the -c, -E, -P, or -S options, or unless compilation errors stop the whole process. so yeah, sometimes she stops early, and honestly? valid.

๐Ÿ”ฅ OPTIONS ๐Ÿ”ฅ

okay first rule of options club: Options must be separate โ€” -cs is different from -c -s. do not smoosh them together, she will not understand you ๐Ÿ’€

here's the full roster, grouped by type, no summarising, we're doing all of them. more detailed explanations are in following sections ๐Ÿซถ


๐ŸŒˆ Overall Options

-- -# -### -c -[no]defaultoptions --diag_errorarg
--diag_remarkarg --diag_suppressarg --diag_warningarg
--display_error_number -dryrun -drystdinc -dumpversion -echo
--flagcheck -flags -fmax-errors=<n> --gcc-toolchain=path
-help[=option] -Manno -Minform=level -Mint128 -Mkeepasm
-M[no]list -noswitcherror -o file -rc rcfile -S -show -silent
-time -V -V<ver> -v --version -W[no]-deprecated-declarations
-Werror -Wpedantic -W[no-]sign-compare -W[no-]unused-but-set-
parameter -W[no-]unused-but-set-variable -W[no-]unused-parameter
-W[no-]unused-variable -w -x language -x none -Wpass,option
-Ypass,directory

โšก Optimization Options

-alias=option -fast -f[no-]cx-limited-range -fastsse -fPIC -fpic
-KPIC -Kpic -M[no]autoinline=option -Mcache_align -Mconcur=option
-M[no]depchk -M[no]dse -Mextract=option -M[no]fma -M[no]frame
-M[no]idiom -M[no]info=option -Minline=option -Minstrument=option
-M[no]ipa=option -M[no]lre[=assoc|noassoc] -M[no]movnt
-Mneginfo=option -Mnoopenmp -Mnosgimp -Mnovintr -Mpfi[=option]
-Mpfo[=option] -M[no]pre -M[no]prefetch=option -Mprof=option
-M[no]propcond -Mquad -Msafe_lastval -M[no]safeptr=option
-M[no-]signed-zeros -M[no]stride0 -M[no]unroll=option
-M[no]unsafe_par_align -M[no]vect=option -M[no]zerotrip
-mp[=option] -nomp -Olevel -pg

๐Ÿ› Debugging Options

-g -gopt -M[no]bounds -Mchkstk -Mcoff -Mdwarf2 -Mdwarf3 -Melf
-Mnodwarf -[no]traceback

๐Ÿงš Preprocessor Options

-C -Dmacro -dD -dI -dM -dN -E -Idirectory -include file
-idirafter directory -isystem directory -iquote directory -M
-Mcpp=[[no]comment|m|md|mm|mmd|mq:target|mt:target|suffix:suff]
-MD -MM -MMD -MQ -MT -Mnostddef -Mnostdinc -Mpreprocess -P
-Umacro -YI,directory -Yp,directory

๐ŸŽ€ Assembler Options

-Wa,argument[,argument]...  -Ya,directory

๐Ÿ‘‘ Linker Options

-acclibs --[no-]as-needed -Bdynamic -Bstatic -Bstatic-nvidia
-Bsymbolic -c++libs -cudaforlibs -cudalib=libname -cudalibs
-fortranlibs -g77libs -Ldirectory -llibrary -m -Mcudalib=libname
-M[no]eh_frame -Mnostartup -Mnostdlib -M[no]rpath -Mmkl -nvmalloc
-pgc++libs -pgf90libs -pthread -Rdirectory -r -rpath directory -s
-shared -soname name -static -static-nvidia -uname
--[no-]whole-archive -Wl,option[,option]... -Xlinker
option[,option]...  -YC,directory -Yl,directory -YL,directory
-YS,directory -YU,directory

๐Ÿ’œ Language Options

-asmsuffix=suffix -B -c8x -c89 -c9x -c99 -c11 -c1x -cuda=option
-csuffix=suffix -fno-builtin -M[no]asmkeyword -M[no]builtin
-M[no]dalign -Mdollar=char -Mfcon -M[no]llalign
-Mlibsuffix=suffix -M[no]m128 -Mobjsuffix=suffix -Mschar
-M[no]signextend -M[no]single -Muchar -M[no]variadic_macros -Xa
-Xc -Xs -Xt

โญ Target-specific Options

-acc -noacc -gpu=option -K[no]ieee -Ktrap=option -march=target
-m[no-]daz-ftz -M[no]daz -M[no]flushz -M[no]fpmisalign
-M[no]fprelaxed=option -M[no]func32 -Mgccbugs -M[no]longbranch
-M[no]second_underscore -Mwritable-strings -mcmodel=small|medium
-ta=target -target=option -tp=target
๐Ÿšจ Note, and this one's important: when source files are compiled using -g, -mp, -Mconcur, -Mipa, or -Mprof, the same option should be used when using nvc to link the objects. like, don't forget to bring the same energy to the link step bestie, she's watching ๐Ÿ‘€

โœจ Overall Options โœจ

  • -- โ€” bestie, everything after this switch is treated as a filename, periodt. That said, most tools will not let a filename start with a dash, so likeโ€ฆ just avoid those? It's giving chaos for no reason. ๐Ÿ’€
  • -# โ€” shows you the invocations of the compiler, assembler, and linker. These invocations are the command lines that nvc itself created โ€” so you get to peek behind the curtain. ๐Ÿ‘€
  • -### โ€” same little show-and-tell as above (compiler, assembler, linker invocations), but it does not execute them. Pure vibes, zero consequences. โœจ
  • -c โ€” skip the link step entirely; compile and assemble only. Baby steps, we're not linking today. ๐ŸŽ€
  • -defaultoptions (default) / -nodefaultoptions โ€” use (or don't use) the default options that live in the site-specific or user-specific PREOPTIONS or POSTOPTIONS driver variables. Yes, those are real variable names, keep them exactly like that. ๐Ÿซถ
  • --diag_errorarg โ€” override the normal error severity of the specified diagnostic message(s). The message(s) may be specified using a mnemonic error tag or using the error number. (The manpage glues the option and its arg together like this โ€” iconic formatting, honestly.) ๐ŸŒธ
  • --diag_remarkarg โ€” override the normal error severity of the specified diagnostic message(s); the message(s) may be specified using a mnemonic error tag or using the error number. ๐Ÿฆ‹
  • --diag_suppressarg โ€” override the normal error severity of the specified diagnostic message(s); the message(s) may be specified using a mnemonic error tag or using the error number. Yes it's the same sentence three times, no I did not make the rules. ๐Ÿ’…
  • --diag_warningarg โ€” override the normal error severity of the specified diagnostic message(s); the message(s) may be specified using a mnemonic error tag or using the error number. That's four diag options, all accounted for, don't come for me. ๐Ÿ˜ญ
  • --display_error_number โ€” shows the error message number inside any diagnostic messages that get generated. Lowkey the useful part: you use this to figure out which error number to plug into the severity-overriding options above. iykyk. ๐Ÿ”ฅ
  • -dryrun โ€” display the invocations of the compiler, assembler, and linker but do not execute them. Rehearsal mode. ๐ŸŽญ
  • -drystdinc โ€” display the standard include directories without invoking the compiler. Just the receipts, no compiling. ๐Ÿงพ
  • -dumpversion โ€” display the shortened version of the compiler. Like 21.11 or 22.3. Short and slay. โญ
  • -echo [=go|stop] โ€” echo the command line flags and (by default) stop. Super handy when the compiler is invoked by a script. ๐Ÿซก
    • go โ€” don't stop after echoing the command line.
    • stop (default) โ€” do stop after echoing the command line.
  • --flagcheck โ€” don't compile anything at all; just emit any messages for command-line switch errors. Returns a success error code if there are no command-line switch errors. Vibe check, but for your flags. โœ…
  • -flags โ€” display all valid nvc command-line options in alphabetical order. Aesthetic. ๐Ÿ’–
  • -fmax-errors=<n> โ€” specify the maximum number of errors before terminating compilation. Yes bestie, there's a limit, we can't be here forever. ๐Ÿ›‘
  • --gcc-toolchain=path โ€” specify the gcc toolchain location using path to the gcc directory or the gcc executable. The argument can either be the gcc root directory, <root directory>/bin, or the gcc executable itself. Flexible queen. ๐Ÿ‘‘
  • -help[=option] โ€” displays command-line options recognized by nvc on the standard output. nvc -help -otherswitch will give help about -otherswitch. The default is to list nvc command line options by group. The options are:
    • groups โ€” print out the groups into which the switches are organized.
    • asm โ€” print help for assembler command-line options.
    • debug โ€” print help for debugging command-line options.
    • language โ€” print help for language-specific command-line options.
    • linker โ€” print help for linker options.
    • opt โ€” print help for optimization command-line options.
    • other โ€” print help for any other command-line options.
    • overall โ€” print help for overall command-line options.
    • phase โ€” print help for the known compiler phases.
    • prepro โ€” print help for preprocessor command-line options.
    • suffix โ€” describe the known file suffixes.
    • switch โ€” print all switches in alphabetical order.
    • target โ€” print help for target-specific command-line options.
    • variable โ€” show the nvc configuration; this is the same as -show.
  • -Manno โ€” produce annotated assembly files, where the source code is intermixed with the assembly language; implies -Mkeepasm. It's giving study guide for your own code. ๐Ÿ“
  • -Minform=level โ€” specify the minimum level of error severity that the compiler displays during compilation. ๐Ÿ’…
    • fatal โ€” instructs the compiler to display fatal error messages.
    • file (default) / nofile โ€” print out (don't print out) the names of files as they are compiled; this is only active when there is more than one file on the command line.
    • severe โ€” instructs the compiler to display severe and fatal error messages.
    • warn โ€” instructs the compiler to display warning, severe and fatal error messages.
    • inform โ€” instructs the compiler to display all error messages (inform, warn, severe and fatal).

The default is -Minform=warn. (Yes, file is also marked default up there โ€” both facts are in the page, I'm not frenching the timeline, I'm just reporting it. ๐Ÿ™ˆ)

  • -Mint128 โ€” enable extended integer types __int128 and unsigned __int128. Big numbers, bigger energy. ๐Ÿ”ข
  • -Mkeepasm โ€” keep the assembly file for each source file, but continue to assemble and link the program. Mainly for compiler performance analysis and debugging, so likeโ€ฆ a niche icon, but an icon. ๐Ÿงš
  • -Mlist / -Mnolist (default) โ€” create (don't create) a listing file. ๐Ÿ—‚๏ธ
  • -noswitcherror โ€” ignore unknown command line switches after printing a warning message. The default behavior is to print an error message and halt. Choose your fighter. โš”๏ธ
  • -o file โ€” use file as the name of the executable program, rather than the default a.out. If used with -c, -P, or -S, and a single input file, file is used as the name of the object, preprocessor, or assembler output file. One flag, several moods. ๐ŸŒˆ
  • -rc rcfile โ€” specifies the name of a nvc startup configuration file. If rcfile is a full pathname, then use the specified file. If rcfile is a relative pathname, use the file name as found in the $DRIVER directory. Remember that env var, it's important. ๐Ÿ’œ
  • -S โ€” skip the assembly and link steps. Leave the output from the compile step in a file named file.s for each file named file.c. Assembly-only era. โœจ
  • -show โ€” produce help information describing the current nvc configuration. ๐Ÿชž
  • -silent โ€” do not print warning messages. Same as -Minform=severe. Shhh. ๐Ÿคซ
  • -time โ€” print execution times for the various steps in the compiler itself. For when you need to know who's slow. โฑ๏ธ
  • -V โ€” display version messages and other information. ๐Ÿท๏ธ
  • -V<ver> โ€” if the specified version of the compiler is installed, that version of the compiler is invoked. Time travel, but legal. ๐Ÿ•ฐ๏ธ
  • -v โ€” verbose mode; print out the command line for each tool before it is executed. Nosy in the best way. ๐Ÿ‘€
  • --version โ€” display version messages and other information. Same energy as -V, different spelling. ๐Ÿ’–
  • -Wdeprecated-declarations / -Wno-deprecated-declarations โ€” emit or suppress warnings about use of functions, variables and types marked as deprecated using the deprecated attribute. ๐Ÿ‘ต
  • -Werror โ€” turn all warning messages into errors. No mercy, no notes. ๐Ÿ”ฅ
  • -Wpedantic / -pedantic โ€” issue strict ANSI warnings. The hall monitor of flags. ๐Ÿ“
  • -Wsign-compare / -Wno-sign-compare โ€” emit or suppress warnings when comparisons are made between signed and unsigned operands. โš–๏ธ
  • -Wunused-but-set-parameter / -Wno-unused-but-set-parameter โ€” emit or suppress warnings when parameters are set but unused. Implies -W[no]-unused-but-set-variable. ๐Ÿซ 
  • -Wunused-but-set-variable / -Wno-unused-but-set-variable โ€” emit or suppress warnings when variables are set but unused. Implies -W[no]-unused-but-set-parameter. They're mutually implying, it's a whole thing. ๐Ÿ’ซ
  • -Wunused-parameter / -Wno-unused-parameter โ€” emit or suppress warnings about unused parameters. ๐Ÿšฉ
  • -Wunused-variable / -Wno-unused-variable โ€” emit or suppress warnings about local variables that are defined but are never referenced. Poor things. ๐Ÿ˜ญ
  • -w โ€” do not print warning messages. (Different from -silent up there, so don't merge them in your head.) ๐Ÿ”‡
  • -x language โ€” specify explicitly the language for the input files (instead of choosing based on the file name suffix). Possible values for language are:
    • c
    • cpp c++ cpp-output
    • f F
    • f95 f95-cpp-input
    • f90 F90
    • f77 f77-cpp-input
    • cuf CUF
    • asm ASM assembler assembler-with-cpp
  • -x none โ€” turn off language specification, so the input files are handled according to their suffixes. Back to autopilot. ๐Ÿ›ผ
  • -Wpass,option[,option...] โ€” pass option to the specified pass. Each comma-delimited option is passed as a separate argument. The passes are:
    • 0 โ€” for the compiler,
    • a โ€” for the assembler,
    • i โ€” for the interprocedural analyzer, and
    • l โ€” for the linker.
  • -Ypass,directory โ€” look in directory for pass pass, rather than in the standard area. The passes are:
    • 0 โ€” search for the compiler executable in directory.
    • a โ€” search for the assembler executable in directory.
    • C โ€” search for the compiler library in directory.
    • i โ€” search for the InterProcedural Analyzer (IPA) in directory.
    • l โ€” search for the linker in directory.
    • I โ€” set the compiler's standard include directory to directory. The standard include directory is set to a default value by the driver and can be overridden by this option.
    • L โ€” if the linker supports the -YL option, then pass the option -YL,directory to the linker. Otherwise, use directory as the standard library location.
    • S โ€” search for the startup object files in directory.
    • U โ€” if the linker supports the -YU option, then pass the option -YU,directory to the linker. Otherwise this option is ignored.

๐ŸŒธ Optimization Options ๐ŸŒธ

  • -alias=option โ€” specifies whether to optimize using ANSI C type-based pointer disambiguation rules. The options can be one of:
  • ansi โ€” assume the ANSI C type-based pointer disambiguation rules apply, which can unlock better optimization in some cases ๐Ÿ”ฅ. The rules say: a load or store through a pointer of any type will not conflict with a load or store of a variable, or through a pointer, of a different type. This is the default with -O2 and above.
  • traditional โ€” assume traditional C semantics apply instead. The compiler assumes a load or store through any pointer might conflict with any variable or pointer dereference unless it can prove otherwise ๐Ÿ˜ค. This is the default with -O1 and below, and also whenever there's a type-cast pointer reference in the function.
  • -fast โ€” picks generally optimal flags for the target platform โœจ. Run nvc -fast -help to see the equivalent switches. Heads up: this sets the optimization level to a minimum of 2; see -O.
  • -fcx-limited-range โ€” says complex division does not need range reduction. -fno-cx-limited-range says complex division does need range reduction. -fcx-limited-range is the default at optimization level -Ofast ๐Ÿ’….
  • -fastsse โ€” picks generally optimal flags for a processor that supports vectorizing for the SSE/AVX instructions ๐Ÿš€. Run nvc -fastsse -help to see the equivalent switches.
  • -fPIC โ€” equivalent to -fpic; it's here for compatibility with other compilers ๐Ÿซถ.
  • -fpic โ€” tells the compiler to generate position-independent code, which you can use to create shared object files (that's dynamically linked libraries, bestie) ๐ŸŽ€.
  • -KPIC โ€” equivalent to -fpic; provided for compatibility with other compilers.
  • -Kpic โ€” equivalent to -fpic; provided for compatibility with other compilers.
  • -Mautoinline[option[,option...], -Mnoautoinline (default) โ€” enables inlining of functions with the inline attribute ๐ŸŒธ. -Mautoinline is implied with the -fast switch. The options are:
    • levels:n โ€” inline up to n levels of function calls; the default is to inline up to 10 levels.
    • maxsize:n โ€” only inline functions with a size of n or less. The size roughly corresponds to the number of statements in the function, though the correspondence is not direct ๐Ÿ™ˆ. The default is to inline functions with a size of 100 or less.
    • totalsize:n โ€” stop inlining when this function reaches a size of n. The default is to stop inlining when a size of 8000 has been reached.
  • -Mcache_align โ€” aligns unconstrained data objects of size greater than or equal to 16 bytes on cache-line boundaries โœจ. An unconstrained object is a variable or array that is not a member of an aggregate structure or common block, is not allocatable, and is not an automatic array. Very demure, very mindful.
โš ๏ธ -Mconcur is deprecated and will be removed in a future release. Like, seriously, don't build your whole personality on it ๐Ÿ˜ญ.
  • -Mconcur[=option[,option,...]] โ€” instructs the compiler to enable auto-concurrentization of loops ๐Ÿ”ฅ. This also sets the optimization level to a minimum of 2; see -O. If -Mconcur is specified, multiple processors will be used to execute loops which the compiler determines to be parallelizable. When linking, the -Mconcur switch must be specified or unresolved references will occur ๐Ÿ’€. The OMP_NUM_THREADS or NCPUS environment variables control how many processors will be used to execute parallelized loops. The options can be one or more of the following:
    • allcores โ€” use all available cores when the environment variables OMP_NUM_THREADS and NCPUS are not set. This must be specified at link time ๐Ÿ‘‘.
    • altcode:n, noaltcode โ€” generate (don't generate) alternate scalar code for parallelized loops. The parallelizer generates scalar code to be executed whenever the loop count is less than or equal to n. If noaltcode is specified, the parallelized version of the loop is always executed regardless of the loop count.
    • altreduction[:n] โ€” generate alternate scalar code for parallelized loops containing a reduction. If a parallelized loop contains a reduction, the parallelizer generates scalar code to be executed whenever the loop count is less than or equal to n.
    • assoc (default), noassoc โ€” enable (disable) parallelization of loops with reductions.
    • cncall, nocncall (default) โ€” assume (don't assume) that loops containing calls are safe to parallelize. Also, no minimum loop count threshold must be satisfied before parallelization will occur, and last values of scalars are assumed to be safe ๐Ÿซถ.
    • dist:block โ€” parallelize with block distribution. Contiguous blocks of iterations of a parallelizable loop are assigned to the available processors.
    • dist:cyclic โ€” parallelize with cyclic distribution. The outermost parallelizable loop in any loop nest is parallelized. If a parallelized loop is innermost, its iterations are allocated to processors cyclically ๐ŸŒ€. For example, if there are 3 processors executing a loop, processor 0 performs iterations 0, 3, 6, etc; processor 1 performs iterations 1, 4, 7, etc; and processor 2 performs iterations 2, 5, 8, etc.
    • innermost, noinnermost (default) โ€” enable (disable) parallelization of innermost loops.
    • levels:n โ€” parallelize loops nested at most n levels deep; the default is 3.
  • -Mdepchk (default), -Mnodepchk โ€” assume (don't assume) that potential data dependencies exist. Heads up bestie: -Mnodepchk may result in incorrect code ๐Ÿ˜ฑ; the -Msafeptr switch provides a less dangerous way to accomplish the same thing.
  • -Mdse, -Mnodse (default) โ€” enable (disable) the dead store elimination optimization.
  • -Mextract=[option[,option,...]] โ€” run the subprogram extraction phase to prepare for inlining ๐Ÿงš. The =lib:filename option must be used with this switch to name an extract library. See -Minline for more details on inlining.
    • subprogram[,subprogram] โ€” a non-numeric option not containing a period is assumed to be the name of a subprogram to be extracted.
    • name:subprogram[,subprogram] โ€” specifies the name of a subprogram or subprograms to be extracted.
    • lib:directory โ€” specifies the name of a directory to contain the extracted subprograms; this directory will be created if it does not exist โœจ.
    • [size:]number โ€” a numeric option is assumed to be a size. Functions containing number or less statements are extracted. If both number and function are specified, then functions matching the given name(s) or meeting the size requirements are extracted.
  • -Mfma, -Mnofma (default) โ€” generate (don't generate) fused multiply-add (FMA) instructions on the CPU and GPU for targets that support it ๐Ÿ”ฅ. FMA instructions are generally faster than separate multiply-add instructions, and can generate higher precision results since the multiply result is not rounded before the addition. Delaying rounding until after addition, however, may cause results to differ from those obtained with the unfused multiply-add instructions ๐Ÿ‘€. FMA instructions are enabled at optimization levels higher than -O1.
  • -Mframe, -Mnoframe (default) โ€” set up (don't set up) a true stack frame pointer for functions; -Mnoframe allows slightly more efficient operation when a stack frame is not needed, but some options override -Mnoframe.
  • -Midiom, -Mnoidiom (default) โ€” enable loop idiom recognition ๐Ÿ’…. Memory copy, memory set, and memory zero loops are recognized and replaced with calls to their respective optimized versions. She ate.
  • -Minfo[=option[,option,...]], -Mnoinfo (default) โ€” emit useful information to stderr ๐ŸŒˆ. The options are:
    • all โ€” includes options accel, inline, ipa, loop, lre, mp, opt, par, stdpar, vect.
    • accel โ€” emit information about accelerator region targeting.
    • ftn โ€” emit Fortran-specific information.
    • inline โ€” emit information about functions extracted and inlined.
    • intensity โ€” deprecated and will be removed in a future version ๐Ÿ™ˆ. Emit compute intensity information about loops.
    • ipa โ€” emit information about the optimizations enabled by interprocedural analysis (IPA).
    • loop | opt โ€” emit information about loop optimizations. This includes information about vectorization and loop unrolling.
    • lre โ€” emit information about loop-carried redundancy elimination.
    • mp โ€” emit information about OpenMP parallel regions.
    • par โ€” emit information about loop parallelization.
    • pfo โ€” emit profile feedback information.
    • time | stat โ€” emit compilation statistics.
    • stdpar โ€” emit information about parallelization of C++ parallel algorithms and Fortran DO CONCURRENT loops.
    • vect โ€” emit information about automatic loop vectorization.

With no options, -Minfo is the same as -Minfo=accel,ipa,loop,lre,mp,opt,par,stdpar,vect ๐Ÿ‘‘

  • -Minline[=option[,option,...]] โ€” pass options to the function inliner ๐ŸŽ€. The options are:
    • lib:filename.ext โ€” specify an inline library created by a previous -Mextract option. Functions from the specified library are inlined. If no library is specified, functions are extracted from a temporary library created during an extract prepass.
    • except:func โ€” specifies which functions should not be inlined.
  • [name:]function โ€” if it's not a number, it's a function name, periodt. And if you write name:, then whatever comes after is always the name of a function, no guessing.
  • pragma โ€” Fortran Only, bestie: inline only those procedures that have a !NVF$ INLINE pragma sitting on the source line immediately before the procedure's SUBROUTINE or FUNCTION statement. Iconic behavior honestly.
  • [maxsize:]number โ€” if it is a number, it's a size. Functions of size number or less get inlined. And if you give both number and function, then functions matching the given name(s) or meeting the size requirements get inlined. Both lanes open ๐Ÿ’…
  • reshape โ€” for Fortran, the default is to not inline subprograms with array arguments when the array shape doesn't match the shape in the caller. This here overrides that default. Rebel move.
  • smallsize:number โ€” always inline functions of size smaller than number, regardless of any other size limits. Tiny functions, immediate VIP access โœจ
  • totalsize:number โ€” stop inlining inside a function once that function's total inlined size reaches the number you specified. Cutoff point, no cap.

  • -Minstrument [=option] โ€” generates extra code so you can do function-level instrumentation. Heads up: this option implies -Mframe. The option is functions (default).
  • -Mipa [=option[,option,...]], -Mnoipa (default) โ€” turns on and configures InterProcedural Analysis (IPA). Big note: IPA is not compatible with parallel make environments (e.g., pmake). Also, IPA sets the optimization level to a minimum of 2 โ€” see -O. If you give no option list at all, it's equivalent to -Mipa=const. The options are:
    • align, noalign (default) โ€” enable (disable) recognition when pointer targets are all cache-line aligned, which lets the compiler make better SSE code generation. Aligned girlies win ๐ŸŒธ
    • arg, noarg (default) โ€” remove (don't remove) arguments that got replaced by -Mipa=ptr,const. FYI -Mipa=noarg implies -Mipa=nolocalarg.
    • const (default), noconst โ€” enable (disable) propagation of constants across procedure calls.
    • f90ptr, nof90ptr (default) โ€” enable (disable) Fortran 90 pointer disambiguation across procedure calls.
    • fast โ€” picks the generally optimal -Mipa flags for the target platform; run nvc -Mipa -help to see the equivalent options. The lazy-girl autopilot ๐ŸŽ€
    • force โ€” force all objects to recompile regardless of whether the IPA information changed.
    • globals, noglobals (default) โ€” analyze (don't analyze) which globals get modified by procedure calls.
    • inline:n โ€” find more functions to inline, allowing up to n levels of inlining. Additional suboptions are:
      • except:proc โ€” disables inlining of procedure proc. Not you, bestie ๐Ÿ’€
      • nopfo โ€” ignore any profile frequency information from -Mpfo when choosing which functions to inline.
      • reshape, noreshape (default) โ€” enable (disable) Fortran inlining with mismatched array shapes.
    • ipofile โ€” save IPA information in a .ipo file instead of the default, which is appending the info to the object file.
    • jobs:n โ€” use up to n jobs in parallel to reoptimize object files. Multitasking queen ๐Ÿ‘‘
    • keepobj (default), nokeepobj โ€” keep (don't keep) the optimized object files, using file name mangling, to reduce recompile time in subsequent application builds.
    • libc, nolibc (default) โ€” optimize calls to certain standard C library routines.
    • libinline, nolibinline (default) โ€” allow (don't allow) inlining from routines in libraries; -Mipa=libinline implies -Mipa=inline.
    • libopt, nolibopt (default) โ€” allow (don't allow) recompiling and reoptimizing routines from libraries with IPA information.
    • localarg, nolocalarg (default) โ€” enable (disable) the feature that externalizes local variables so arguments can be replaced by -Mipa=ptr. Note: -Mipa=localarg implies -Mipa=arg.
    • main:func โ€” specify a function to serve as a global entry point; may appear multiple times; this disables linking.
    • ptr, noptr (default) โ€” enable (disable) pointer disambiguation across procedure calls.
    • pure, nopure (default) โ€” detect (don't detect) pure functions.
    • quiet โ€” don't print out messages about which files are being recompiled at link time. Silence is golden, honestly.
    • reaggregation, noreaggregation (default) โ€” enable (disable) global struct reaggregation. This one can change the order of struct members, or split structs into multiple structs, to improve memory locality and cache utilization ๐Ÿ‘€
    • required โ€” return an error condition if IPA gets inhibited for any reason, instead of the default behavior of just linking without IPA optimization.
    • safe:[function|library] โ€” declares that the named function, or all functions in the named library, are safe; a safe procedure does not call back into the known procedures and does not change any known global variables. Without -Mipa=safe, any unknown procedures will cause IPA to fail. Trust issues fr fr ๐Ÿ˜ญ
    • safeall, nosafeall (default) โ€” declares that all unknown functions are safe (not safe); see -Mipa=safe.
    • shape, noshape (default) โ€” perform (don't perform) Fortran 90 shape propagation.
    • summary โ€” only collect IPA summary information when compiling; this prevents IPA optimization of this file, but allows optimization for other files linked with this file. Team player energy ๐Ÿซถ
    • vestigial, novestigial (default) โ€” remove (don't remove) functions that are not called. Bye to the npcs โœŒ๏ธ
  • -Mlre[=assoc|noassoc], -Mnolre โ€” enable (disable) loop-carried redundancy elimination. The assoc option allows expression reassociation, and the noassoc option disallows expression reassociation.
  • -Mmovnt, -Mnomovnt โ€” force (disable) generation of nontemporal moves. Fun fact: -Mmovnt used with -fastsse can sometimes be faster than -fastsse alone. By default, nontemporal moves are generated for loops with large loop counts.
  • -Mneginfo=option[,option...] โ€” tells the compiler to produce information on why certain optimizations are not performed. Um, use the -Minfo flag instead ๐Ÿ’…
  • -Mnoopenmp โ€” when -mp is present, ignore the OpenMP pragmas.
  • -Mnosgimp โ€” when -mp is present, ignore the SGI parallelization pragmas.
  • -Mnovintr โ€” do not generate vector intrinsic calls.
  • -Mpfi[=option] โ€” generate profile feedback instrumentation; this includes extra code to collect run-time statistics to be used in a subsequent compile; -Mpfi must also appear when the program is linked. When the program is run, a profile feedback file pgfi.out will be generated; see -Mpfo. The allowed options are:
    • indirect, noindirect (default) โ€” enable (disable) collection of indirect function call targets, which can be used for indirect function call inlining.
  • -Mpfo[=option[,option,...]] โ€” enable profile feedback optimizations; there must be a profile feedback file pgfi.out in the current directory, which contains the result of an execution of the program compiled with -Mpfi. The options are:
    • indirect, noindirect (default) โ€” enable (disable) indirect function call inlining; this requires a pgfi.out file generated from a binary built with -Mpfi=indirect.
    • layout (default), nolayout โ€” enable (disable) basic block layout to take advantage of instruction cache locality by keeping hot paths close together. Hot paths stay close, that's the whole vibe ๐Ÿ”ฅ
    • dir=directory โ€” specify the directory containing the pgfi.out profile feedback information file; the default is the current directory.
  • -Mpre, -Mnopre (default) โ€” enable (disable) the partial redundancy elimination optimization.
  • -Mprefetch[=option:n], -Mnoprefetch โ€” add (don't add) prefetch instructions for those processors that support them (Pentium 4, Opteron); -Mprefetch is default on Opteron; -Mnoprefetch is default on other processors. The options are:
    • distance:d โ€” set the fetch-ahead distance for prefetch instructions to d cache lines.
    • n:n โ€” set the maximum number of prefetch instructions to generate in a loop to n.
    • nta โ€” use the prefetchnta instruction.
    • plain โ€” use the prefetch instruction.
    • t0 โ€” use the prefetcht0 instruction.
    • w โ€” allow the AMD-specific prefetchw instruction.
  • -Mprof[=option[,option,...]] โ€” set performance profiling options. Using these options will cause the resulting executable to create a performance profile that can be viewed and analyzed with the PGPROF performance profiler. In the descriptions below, old-style profiling implies compiler-generated source instrumentation, and MPICH-style profiling implies the use of instrumented wrappers for MPI library routines. The -Mprof options are:
    • dwarf โ€” generate limited DWARF symbol information sufficient for most performance profilers.
    • func โ€” perform old-style function level profiling.
    • hwcts โ€” generate a profile using event-based sampling of hardware counters via the PAPI interface (PAPI must be installed, no cap).
    • lines โ€” perform old-style line level profiling.
  • time โ€” makes a profile using time-based instruction-level statistical sampling. It's literally the same as -pg, except the profile gets saved to a file called pgprof.out instead of gmon.out. ๐Ÿ•

On Linux systems with OProfile installed, PGPROF can collect performance data without recompiling. And for that mode of profiling, -Mprof=dwarf is the vibe. ๐Ÿงš


  • -Mpropcond (default) / -Mnopropcond โ€” turn on (or off) propagation of constant values that come from conditional branches with equality tests. โœจ
  • -Mquad โ€” align large objects on quad-word boundaries. bougie alignment behavior, no cap. ๐Ÿ’…
  • -Msafe_lastval โ€” okay so sometimes a scalar gets used after a loop but isn't defined on every iteration of that loop, and by default the compiler is like "nope, not parallelizing that." This option tells the compiler "bestie it's safe, go parallelize it." ๐Ÿซถ
  • -Msafeptr[=option[,option,...]] / -Mnosafeptr (default) โ€” override (or don't override) data dependence between C pointers, and between pointers and variables or arrays.
โš ๏ธ Use this one with care โ€” there's real potential for the compiler to generate code that gives unexpected or incorrect results as defined by ANSI C. But when you use it properly, it can massively enhance performance, especially for floating-point oriented loops. You can combine the options and they'll interact appropriately. ๐Ÿ”ฅ
  • all โ€” all pointers are assumed not to overlap or conflict with other data objects. -Msafeptr with no options implies -Msafeptr=all.
  • arg | dummy โ€” C dummy arguments (pointers and arrays) get treated with the same copyin/copyout semantics as Fortran dummy arguments.
  • auto | local โ€” C local or auto variables (pointers and arrays) are assumed not to overlap or conflict with other data objects, and are independent.
  • global โ€” C global or extern variables (pointers and arrays) are assumed not to overlap or conflict with other data objects, and are independent.
  • static โ€” C static variables (pointers and arrays) are assumed not to overlap or conflict with other data objects, and are independent.
  • -Msigned-zeroes (default) / -Mno-signed-zeros โ€” toggles whether to honor (-Msigned-zeros) or ignore (-Mno-signed-zeros) issues associated with a signed 0.0 during optimization. ๐Ÿ“
  • -Mstride0 / -Mnostride0 (default) โ€” generate (or don't generate) alternate code for a loop containing an induction variable whose increment may be zero. ๐ŸŒ€
  • -Munroll[=option[,option...]] / -Mnounroll (default) โ€” invoke (or don't invoke) the loop unroller. This also sets the optimization level to a minimum of 2; see -O. The option is one of these:
    • c:m โ€” tells the compiler to completely unroll loops with a constant loop count less than or equal to m, a supplied constant. If you don't supply this value, the m count is set to 1. If m is set to 1, a compiler heuristic determines the maximum loop count at which such loops will be completely unrolled.
    • n:u โ€” tells the compiler to unroll u times, a single-block loop which is not completely unrolled, or has a non-constant loop count. If u isn't supplied, the unroller computes the number of times a candidate loop is unrolled.
    • m:u โ€” tells the compiler to unroll u times, a multi-block loop which is not completely unrolled, or has a non-constant loop count. If u isn't supplied, the unroller computes the number of times a candidate loop is unrolled.

And -Mnounroll instructs the compiler not to unroll loops. periodt.

  • -Munsafe_par_align / -Mnounsafe_par_align โ€” use (or don't use) aligned moves for array loads in parallelized loops, as long as the first element of the array is aligned. This is only effective with -Mvect=simd. It's called unsafe for a reason: there are situations where the array elements allocated to some processors are not aligned. ๐Ÿ’€
  • -Mvect [=option[,option,...]] / -Mnovect (default) โ€” passes options to the internal vectorizer. This also sets the optimization level to a minimum of 2, the equivalent of -O โ€” for more info see optimization levels under -O. If you don't specify an option list, then these vector optimizations are used: assoc,cachesize:c,simd:256, where c is the actual cache size of the machine. The -Mvect options are:
    • altcode (default) / noaltcode โ€” enable (or disable) alternate code generation for vector loops, depending on characteristics like array alignments and loop counts.
    • fuse / nofuse (default) โ€” enable (or disable) loop fusion, which combines adjacent loops into a single loop. ๐Ÿฆ‹
    • prefetch โ€” use prefetch instructions in loops where it's profitable.
    • simd[:{128|256|512}] (default) / nosimd โ€” use vector SIMD instructions (AVX, AVX2, AVX512). The argument can limit usage to 128-bit SIMD instructions. Specifying 512-bit SIMD instructions is only possible for target processors that support AVX512. ๐Ÿ‘‘
    • uniform / nouniform (default) โ€” perform the same optimizations in the vectorized and residual loops. Heads up: this may affect the performance of the residual loop.

These options are also supported, but not recommended for use in new development (except by experienced users), and they may be phased out in future releases:

  • assoc (default) / noassoc โ€” enable (or disable) certain associativity conversions that can change the results of a computation due to floating-point roundoff error differences. A typical optimization is changing the order of additions, which is mathematically correct but can be computationally different because of roundoff error. ๐Ÿงฎ
  • cachesize:number (default=automatic) โ€” tells the vectorizer, when doing cache tiling optimizations, to assume a cache size of number.
  • gather (default) / nogather โ€” enable (or disable) vectorization of loops with indirect array references.
  • idiom (default) / noidiom โ€” enable idiom recognition; an alternate form of -Midiom.
  • levels:n โ€” set the maximum nest level of loops to optimize.
  • partial โ€” enable partial loop vectorization via innermost loop distribution.
  • short / noshort (default) โ€” enable (or disable) recognition of short vector operations that arise from scalar code outside of loops or within the body of loops.
  • sizelimit[:number] / nosizelimit (default) โ€” limit the size of loops that get vectorized; the default is to attempt to vectorize all loops.
  • tile / notile (default) โ€” enable (or disable) loop tiling to optimize for cache locality.

And -Mnovect disables the vectorizer โ€” it's the default at -O0 and -O1.

  • -Mzerotrip (default) / -Mnozerotrip โ€” include (or don't include) a zero-trip test for loops. Only use -Mnozerotrip when all loops are known to execute at least once. ๐Ÿ™ˆ

  • -mp[=option] โ€” enable OpenMP pragmas and directives to explicitly parallelize regions of code so they can run on accelerator devices or multiprocessor systems. The allowed options are:
    • gpu โ€” compile OpenMP directives for parallel execution on the GPU. ๐ŸŽฎ
    • multicore (default) โ€” compile OpenMP directives for parallel execution on the CPU.
    • align / noalign (default) โ€” modify (or don't modify) default loop iteration scheduling so iterations align with array references. The default is to use simple static scheduling.
    • autopar (default) / noautopar โ€” enable loop autoparallelization of omp loop constructs.
    • ompt โ€” link against an OMPT-enabled OpenMP library.
  • -nomp โ€” ignore OpenMP directives and don't link against OpenMP runtime libraries. โœŒ๏ธ

๐Ÿ”ฅ OPTIONS: the -O levels (the main character energy section)

  • -O[level] โ€” sets the optimization level. If you don't specify -O, then the default level is 1 if -g isn't specified, and 0 if -g is specified. If you don't give a number with -O, the optimization level is set to 2. Here's what each level means:
    • -O0 โ€” sets the optimization level to 0. A basic block is generated for each statement. No scheduling is done between statements. No global optimizations are performed. it's giving raw and unbothered. ๐Ÿ’€
    • -O1 โ€” sets the optimization level to 1. Scheduling within extended basic blocks is performed. No global optimizations are performed.
    • -O โ€” sets the optimization level to 2, with no SIMD vectorization enabled. All level 1 optimizations are performed. Plus, traditional scalar optimizations like induction recognition and loop invariant motion are performed by the global optimizer.
    • -O2 โ€” all -O optimizations are performed. Plus, more advanced optimizations like SIMD code generation, cache alignment and partial redundancy elimination are enabled. โœจ
    • -O3 โ€” all -O1 and -O2 optimizations are performed. Plus, this level enables more aggressive code hoisting and scalar replacement optimizations that may or may not be profitable.
    • -Ofast โ€” enables -O3, -Mfprelaxed, -Mstack_arrays, -Mno-nan, Mno-inf, and -fcx-limited-range. Note that -Mstack_array is disabled when both the command line options -Ofast and -stdpar are enabled. ๐ŸŽ๏ธ
  • -O4 โ€” all the -O1, -O2, and -O3 optimizations are performed. On top of that, hoisting of guarded invariant floating-point expressions is enabled. ๐Ÿ’…
  • -pg โ€” enable gprof-style sample-based profiling; implies -Mframe. ๐Ÿ‘‘

๐Ÿž Debugging Options ๐Ÿž

okay bestie, this is the debugging section โ€” lowkey important, highkey iconic. ๐Ÿ› ๏ธ

  • -g โ€” generate symbolic debug information. This also sets the optimization level to zero, unless a -O switch is present on the command line. Symbolic debugging may give confusing results if an optimization level other than zero is selected. Using -O0, the generated code will be slower than code generated at other optimization levels. ๐Ÿ˜ญ
  • -gopt โ€” generate symbolic debug information, without affecting optimizations. This may give confusing results when debugging with optimizations; it is intended for use with other tools that use the debug information. ๐Ÿงš
  • -Mbounds โ€” add array bounds checking. ๐Ÿšจ
  • -Mnobounds (default) โ€” don't add array bounds checking. ๐Ÿšซ
Bounds checking is not applied to a subscripting pointer. ๐Ÿ’€
  • -Mchkstk โ€” check the stack for available space upon entry to and before the start of a parallel region. Useful when many private variables are declared. ๐Ÿ“š
  • -Mcoff โ€” generate a COFF formatted object. ๐Ÿ“ฆ
  • -Mdwarf2 โ€” generate DWARF2 debug information with -g. ๐Ÿงฌ
  • -Mdwarf3 โ€” generate DWARF3 debug information with -g. ๐Ÿงฌ
  • -Melf โ€” generate an ELF formatted object. ๐Ÿง
  • -Mnodwarf โ€” don't add the default dwarf information. ๐Ÿ™…
  • -traceback, -notraceback (default) โ€” add debug information for runtime traceback. (-notraceback is the default.) ๐Ÿงต

โœจ Preprocessor Options โœจ

this is where the preprocessor does its little main-character thing. ๐ŸŽ€

  • -C โ€” preserve comments in preprocessed C source files. ๐Ÿ’ฌ
  • -Dname[=def] โ€” define name to be def in the preprocessor. If def is missing, it is assumed to be empty. If the = sign is missing, then name is defined to be the string 1. ๐Ÿท๏ธ
  • -dD โ€” print to standard output a list of the macros and their values as defined in the source files, along with the file name and line number where the definitions occur. ๐Ÿ“
  • -dI โ€” print to standard output a list of all files included by the preprocessor, including the file name and line number where the include line occurred, and the full path of the included file. ๐Ÿ“‚
  • -dM โ€” print to standard output a list of all the macros and their values as defined in the source files, along with the file name and line number where the definitions occur, as well as predefined and command-line macros. ๐Ÿ”
  • -dN โ€” like -dD, print to standard output a list of macro names, but not their values, as defined in the source files, along with the file name and line number where the definitions occur. ๐Ÿท๏ธ
  • -E โ€” preprocess each .c file and send the result to standard output. No compilation, assembly, or linking is performed. ๐Ÿš€
  • -Idirectory โ€” add directory to the compiler's search path for include files. For include files surrounded by < >, each -I directory is searched followed by the standard area. For include files surrounded by " ", the directory containing the file containing the #include directive is searched, followed by the -I directories, followed by the standard area. ๐Ÿงญ
  • -include file โ€” include the source code of the indicated file at the beginning of the compilation. ๐ŸŒฑ
  • -idirafter directory โ€” add a directory to the end of the include file search path, after the standard include directories, and mark it as a system include directory. ๐Ÿ
  • -isystem directory โ€” same as -I, but mark the directory as a system directory. ๐Ÿ›ก๏ธ
  • -iquote directory โ€” add a directory to the beginning of the include file search path, and use it only when processing includes with quotes. ๐Ÿ’ฌ
  • -M โ€” generate a list of make dependences and print them to stdout. -MQ and -MT are synonyms. ๐Ÿ“‹
  • -Mcpp=[[no]comment|m|md|mm|mmd|mq:target|mt:target|suffix:suff] โ€” only runs the preprocessor on the input file(s); by default, the output is written to file.i, unless renamed with the -o switch. The options are:
    • comment nocomment โ€” keep (don't keep) C-style comments in the preprocessed output. ๐Ÿ’ฌ
    • include:file โ€” include this file before processing the source file. ๐ŸŒฑ
    • m โ€” print makefile dependencies to stdout, a la -M. ๐Ÿ“‹
    • md โ€” print makefile dependencies to file.d, a la -MD. ๐Ÿ“„
    • mm โ€” print makefile dependencies to stdout, ignoring system includes (includes with angle braces), a la -MM. ๐Ÿ“‹
    • mmd โ€” print makefile dependencies to file.d, ignoring system includes (includes with angle braces), a la -MMD. ๐Ÿ“„
    • mq:'target' โ€” print makefile dependencies to stdout, a la -MQ. ๐Ÿ“‹
    • mt:target โ€” print makefile dependencies to stdout, a la -MT. ๐Ÿ“‹
    • line โ€” include line numbers into the preprocessed output. ๐Ÿ”ข
    • suffix:suff โ€” when generating makefile dependencies, name the dependent file file.suff; the default is to name the dependent file file.o. ๐Ÿท๏ธ
  • -MD โ€” generate a list of make dependences and print them to the file file.d, where file is the root name of the file under compilation. ๐Ÿ“„
  • -MM โ€” generate a list of make dependences and print them to stdout; ignore system includes. ๐Ÿ“‹
  • -MMD โ€” generate a list of make dependences and print them to the file file.d, where file is the root name of the file under compilation. Ignore system includes. ๐Ÿ“„
  • -MQ โ€” generate a list of make dependences and print them to stdout. ๐Ÿ“‹
  • -MT โ€” generate a list of make dependences and print them to stdout. ๐Ÿ“‹
  • -Mnostddef โ€” do not predefine any macros to the preprocessor. ๐Ÿšซ
  • -Mnostdinc โ€” do not search in the standard location for include files when those files are not found elsewhere. ๐Ÿšซ
  • -Mpreprocess โ€” run the preprocessor on assembler source files. โš™๏ธ
  • -P โ€” preprocess each file and leave the output in a file named file.i for each file named file.c. ๐Ÿ“„
  • -Uname โ€” remove the definition of the name macro in the preprocessor. ๐Ÿ—‘๏ธ
  • -YI,directory โ€” change the standard include directory to directory. ๐Ÿ“
  • -Yp,directory โ€” look in directory for the preprocessor executable. ๐Ÿ”

โš™๏ธ Assembler Options โš™๏ธ

  • -Wa,option[,option...] โ€” pass each comma-delimited option to the assembler. ๐Ÿ› ๏ธ
  • -Ya,directory โ€” look in directory for the assembler executable. ๐Ÿ”

๐Ÿ’– Linker Options ๐Ÿ’–

okay bestie, this is the link-line zone: every flag here gets passed along to the linker (or tells the driver what to put on the link line), and the facts stay exactly the same. no cap. ๐Ÿซถ

  • -acclibs โ€” link-time option to add the accelerator libraries to the link line. โœจ
  • --as-needed, --no-as-needed โ€” passed to the linker. says only set the DT_NEEDED flag for subsequent shared libraries, requiring those libraries at run time, if they are used to satisfy references. --no-as-needed restores the default behavior.
  • -Bdynamic โ€” passed to the linker to specify dynamic binding. ๐Ÿ’…
  • -Bstatic โ€” same as -static; go check -static for the details.
  • -Bstatic-nvidia โ€” same as -static-nvidia; go check -static-nvidia for the details.
  • -Bsymbolic โ€” passed to linker; specify symbolic binding.
  • -c++libs โ€” link-time option to add the C++ runtime libraries, allowing mixed-language programming. ๐ŸŽ€
  • -cudaforlibs โ€” link-time option to add the CUDA Fortran runtime libraries, allowing mixed-language programming. implies -fortranlibs.
  • -cudalib[=libname[,libname...]] โ€” add CUDA-optimized libraries to the link line. when no option is specified the compiler will link all necessary CUDA-optimized libraries. -cudalib will use the version of the library appropriate to the CUDA version being used. the libraries recognized are:
    • cublas
    • cublasmp
    • cufft
    • cufftmp
    • cufftw
    • curand
    • cusolver
    • cusolvermp
    • cusparse
    • cutensor
    • nccl
    • nvblas
    • nvshmem
    • nvtx3
  • -cudalibs โ€” this option has been deprecated; please refer to -cudalib. link-time option to add the CUDA runtime API library. ๐Ÿ’€
  • -fortranlibs โ€” link-time option to add the Fortran runtime libraries, allowing mixed-language programming.
  • -g77libs โ€” link-time option which allows object files generated by GNU g77 (or gcc) to be linked in to nvc main programs. ๐Ÿ”ฅ
  • -Ldirectory โ€” passed to the linker; add directory to the list of directories in which the linker searches for libraries.
  • -llibrary โ€” passed to the linker; load the library liblibrary.a from the standard library directory. see also the -L option.
  • -m โ€” cause the linker to display a link map. ๐Ÿ—บ๏ธ
  • -Mcudalib[=libname[,libname...]] โ€” this option has been deprecated; please refer to -cudalib. add CUDA-optimized libraries to the link line. when no option is specified the compiler will link all necessary CUDA-optimized libraries. ๐Ÿ™ˆ
  • -Meh_frame, -Mnoeh_frame โ€” add (don't add) arguments to the link line to preserve the stack frame information for zero-cost exception handling frames. the default is -Mnoeh_frame unless changed in a site or user rcfile.
  • -Mnostartup โ€” do not link in the usual startup routine. this routine contains the entry point for the program.
  • -Mnostdlib โ€” do not link in the standard libraries when linking a program.
  • -Mrpath (default), -Mnorpath โ€” the default is to add -rpath to the link line giving the directories containing the required runtime shared objects. use -Mnorpath to instruct the driver not to add any -rpath switches to the link line.
  • -Mmkl โ€” add Intel's Math Kernel libraries to the link line. requires that the environment variable MKLROOT be set to the path to the local MKL installation (the part of the path that precedes 'lib/<arch>'). ๐Ÿงš
  • -nvmalloc โ€” use a custom host memory allocator.
  • -pgc++libs โ€” link-time option to add the C++ runtime libraries, allowing mixed-language programming.
  • -pgf90libs โ€” link-time option to add the PGF90 runtime libraries, allowing mixed-language programming.
  • -pthread โ€” adds support for multithreading with the pthreads library. this option sets flags for both the preprocessor and linker. ๐Ÿงต
  • -Rdirectory โ€” passed to the linker; instructs the linker to hard-code the pathname directory into the search path for generated shared object files. note that there cannot be a space between R and directory. โš ๏ธ
  • -r โ€” passed to the linker; generate a re-linkable object file.
  • -rpath directory โ€” passed to the linker to add the directory to the runtime shared library search path.
  • -s โ€” passed to the linker; strip symbol table information.
  • -shared โ€” passed to the linker. instructs the linker to generate a shared object file (dynamically linked library). implies -fpic.
  • -soname name โ€” passed to the linker. when creating a shared object, instructs the linker to set the internal DT_SONAME field to the specified name.
  • -static โ€” passed to the linker to specify static binding.
  • -static-nvidia โ€” statically link in the NVIDIA runtime libraries, while using dynamic linking for the system libraries; implies -Mnorpath. ๐Ÿ‘‘
  • -uname โ€” passed to the linker; generate undefined reference.
  • --whole-archive, --no-whole-archive โ€” passed to the linker. instructs the linker to include all objects in subsequent archive files. --no-whole-archive restores the default behavior.
  • -Wl,option[,option]..., -Xlinker option[,option]... โ€” pass each comma-delimited option to the linker.
  • -YC,directory โ€” look in directory for the standard compiler library files.
  • -Yl,directory โ€” look in directory for the linker.
  • -YL,directory โ€” change the standard library directory to directory.
  • -YS,directory โ€” look in directory for the standard system startup object files.
  • -YU,directory โ€” passed to the linker; change library search path.

๐ŸŒธ Language Options ๐ŸŒธ

this is the language-flavor section, aka where you tell the compiler what counts as C, what counts as assembly, and which little language-lawyer rules are in effect. periodt. ๐Ÿ’œ

  • -asmsuffix=suffix โ€” define that a file with the given suffix is an assembly language file.
  • -B โ€” allow C++-style comments in source code; these begin with the characters // and continue to the end of the current line. such comments are stripped unless you specify the -C option. ๐Ÿ’ฌ
  • -c8x โ€” use the C89 standard as the C source language.
  • -c89 โ€” use the C89 standard as the C source language.
  • -c9x โ€” use the C99 standard as the C source language.
  • -c99 โ€” use the C99 standard as the C source language.
  • -c11 โ€” use the C11 standard as the C source language.
  • -c1x โ€” use the C11 standard as the C source language.
  • -cuda[=option[,option...] โ€” enable CUDA Fortran; add CUDA include paths, and link with the CUDA runtime libraries. -cuda is required on the link line. if -cuda is used in compilation, it must also be used for linking. for target specific options, please refer to -gpu. for linking additional CUDA libraries (e.g. math libraries), please refer to -cudalib. use the following sub-options to tailor the compilation of CUDA Fortran accelerator regions:
    • charstring โ€” enable limited support for character strings in GPU kernels.
    • madconst โ€” put Module Array Descriptors in CUDA Constant Memory.
  • -csuffix=suffix โ€” define that a file with the given suffix is a C source file.
  • -fno-builtin โ€” same as -Mno-builtin; please refer to -Mno-builtin for details.
  • -Masmkeyword, -Mnoasmkeyword (default) โ€” allow (don't allow) the asm keyword in C source code. the format is: asm("<text>"). ๐Ÿงฉ
  • -Mbuiltin (default), -Mnobuiltin โ€” compile (don't compile) with math subroutine builtin support, which causes selected math library routines to be inlined.
  • -Mdalign (default), -Mnodalign โ€” align (don't align) doubles in structures on 8-byte boundaries. -Mnodalign may lead to data alignment exceptions. โš ๏ธ
  • -Mdollar=char โ€” set the character used to replace dollar signs in names to be char. default is an underscore (_).
  • -Mfcon โ€” treat non-suffixed floating-point constants as float, rather than double. this may improve the performance of single-precision code. ๐Ÿ“
  • -Mllalign (default), -Mnollalign โ€” align (don't align) long longs or INTEGER*8 in structures or common blocks on 8-byte boundaries. -Mllalign is the default.
  • -Mlibsuffix=suffix โ€” define that a file with the given suffix is an object library file.
  • -Mm128, -Mnom128 (default) โ€” recognize the datatypes __m128, __m128d and __m128i.
  • -Mobjsuffix=suffix โ€” define that a file with the given suffix is a binary object file.
  • -Mschar (default) โ€” specify that the char type is signed by default; see -Muchar.
  • -Msignextend (default), -Mnosignextend โ€” sign extend (don't sign extend) when a narrowing conversion overflows. for example, when -Msignextend is in effect and an integer containing the value 65535 is converted to a short, the value of the short will be -1. ANSI C specifies that the result of such conversions are undefined. ๐Ÿ˜ญ
  • -Msingle, -Mnosingle (default) โ€” suppress (don't suppress) the ANSI-specified conversion of float to double when passing arguments to a function with no prototype in scope. -Msingle may result in faster code when single precision is used a lot, but is non-ANSI compliant. ๐Ÿ’…
  • -Muchar โ€” specify that the char type is unsigned by default; see -Mschar.
  • -Mvariadic_macros, -Mnovariadic_macros โ€” allow (disallow) variadic macros. variadic macros are enabled by default.
  • -Xa โ€” ANSI mode: specify that the compiled language should conform to all ANSI features.
  • -Xc โ€” conformance mode: specify that the compiled language should conform to all ANSI features, but warnings may be produced about some extensions.
  • -Xs โ€” standard mode: specify that the compiled language should conform to K&R C. this also implies -ansi=traditional.
  • -Xt โ€” specify that the compiled language should conform to K&R C. the compiler may produce warnings for semantics where ANSI C and K&R C conflict. this also implies -ansi=traditional.

๐ŸŽฏ Target-specific Options ๐ŸŽฏ

  • -acc โ€” enable OpenACC pragmas and directives to explicitly parallelize regions of code for execution by accelerator devices. see the -gpu flag to select options specific to NVIDIA GPUs. the options are:
  • autopar (default), noautopar โ€” enable loop autoparallelization within parallel constructs; noautopar turns it off. ๐Ÿ”ฅ
  • gpu (default) โ€” compile OpenACC directives for parallel execution on the GPU. ๐Ÿ‘‘
  • host โ€” compile OpenACC directives for serial execution on the host CPU.
  • legacy โ€” suppress warnings about deprecated PGI accelerator directives.
  • multicore โ€” compile OpenACC directives for parallel execution on the host CPU.
  • routinepar, noroutinepar (default) โ€” infer the parallelism level clause (gang, worker, vector) in implicit routine directives.
  • routineseq, noroutineseq (default) โ€” compile every routine for the device, as if it had a routine seq directive.
  • strict โ€” issue warnings when accelerator directives are encountered which do not adhere to the OpenACC standard.
  • sync โ€” ignore async clauses, and run every data transfer and kernel launch on the default sync queue.
  • verystrict โ€” abort compilation with a fatal error when an accelerator directive is encountered which does not adhere to the OpenACC standard. Like, full stop, no vibes. ๐Ÿ’€
  • wait (default), nowait โ€” wait for each compute kernel to finish; nowait says donโ€™t. ๐Ÿซถ
  • -noacc โ€” disable OpenACC directives and do not link with OpenACC libraries.
  • -gpu=option โ€” use the following sub-options to tailor the compilation of target accelerator regions:
    • autocompare โ€” automatically compare CPU/GPU results. Accelerated code sections will be run in redundant mode, and data will be compared whenever it would ordinarily be moved off the accelerator. ๐Ÿงš
    • ccXY โ€” generate code for a device with compute capability XY. Multiple compute capabilities can be specified, and one version will be generated for each. By default, the compiler will detect the compute capability for each installed GPU. Use -help -gpu to see the valid compute capabilities for your installation.
    • ccall โ€” generate code for all compute capabilities supported for this target and by the selected CUDA Toolkit version.
    • ccnative โ€” detects the visible GPUs on the system and generates codes for them. If no device is available the default compute capability will be used (cc50).
    • ccall-major โ€” compile for all major supported compute capabilities (does not include PTX for the highest major virtual architecture, see -gpu=[no]rdc option for that support).
    • cudaX.Y โ€” use CUDA X.Y Toolkit compatibility, where installed.
    • deepcopy โ€” enable Full Deepcopy support in OpenACC Fortran. ๐Ÿ“
    • fastmath โ€” enable the fast math library, which includes faster, but lower precision, implementations of certain math and intrinsic functions.
    • flushz, noflushz (default) โ€” enable (disable) flush-to-zero mode on the GPU.
    • fma, nofma โ€” generate (do not) fused multiply-add operations on the GPU. This is enabled by default at optimization level -O1.
    • implicitsections, noimplicitsections (default) โ€” change (do not change) array element references in OpenACC and OpenMP data clause to array sections references.
    • interceptdeallocations, nointerceptdeallocations โ€” intercept (do not intercept) LIBC function calls (e.g. free) and call the corresponding CUDA memory deallocation version if address is in pinned or managed memory, regular version otherwise.
    • keepbin โ€” keep the generated CUDA binary, with a .cubin suffix.
    • keepgpu โ€” keep the generated CUDA GPU source files, with a .gpu suffix.
    • keepltoir โ€” keep the generated GPU LTOIR files, with a .ltoir suffix. Works only when -gpu=lto is enabled.
    • keepptx โ€” keep the generated portable assembly files, with a .ptx suffix.
    • lineinfo, nolineinfo (default) โ€” generate debugging line information.
    • loadcache:[L1|L2] โ€” generate code to cache global memory loads in the L1 or L2 hardware cache.
    • lto โ€” enable Device Link Ltime Optimization (Device LTO). ๐ŸŒ€
    • maxregcount:n โ€” set the maximum number of registers to use in the generated GPU code.
    • managed โ€” allocate any dynamically allocated data in CUDA Managed memory. This option must appear in both the compile and link lines. This option may not be used with -gpu=pinned.
      • intercept โ€” intercept LIBC function calls (e.g. free) and call their managed memory version if address is in managed memory, regular version otherwise. ๐Ÿซถ
    • nomanaged โ€” do not allocate any dynamically allocated data in CUDA Managed memory. Use with -stdpar to prevent that flag's implicit use of -gpu=managed when CUDA Managed memory capability is detected.
    • nounified โ€” do not compile for CUDA Unified memory capability. Use with -stdpar to prevent that flag's implicit use of -gpu=unified when CUDA Unified memory capability is detected.
    • pinned โ€” allocate any dynamically allocated data in CUDA Pinned host memory. This option must appear in both the compile and link lines. This option may not be used with -gpu=managed|unified.
      • intercept โ€” intercept LIBC function calls (e.g. free) and call their pinned memory version if address is in pinned memory, regular version otherwise. ๐Ÿ’…
    • mem:[mode] โ€” select GPU memory mode from one of the following options: separate, managed, unified. This option cannot be combined with -gpu=pinned, gpu=managed or -gpu=unified.
      • mem:separate โ€” all data are in separate CPU and GPU memories. Explicit memory copies are performed when data are accessed from both CPU and GPU.
      • mem:managed โ€” allocate any dynamically allocated data in CUDA Managed Memory. Data that are not allocated dynamically are in separate GPU memory and are copied explicitly between CPU and GPU memories. This option must appear in both the compile and link lines.
      • mem:unified โ€” compile for full CUDA Unified Memory capability, where system memory is accessible from the GPU. All variables in the CPU code are accessible from the GPU without explicit directives or attributes. This mode utilizes system and managed memory for dynamically allocated data unless explicit behavior is set through -gpu=mem:unified:[no]managedalloc subflags. This option must appear in both the compile and link lines. ๐ŸŒˆ
    • mem:unified:managedalloc, mem:unified:nomanagedalloc โ€” allocate (do not allocate) any dynamically allocated data in CUDA Managed Memory.
    • mem:separate:pinnedalloc, mem:separate:nopinnedalloc โ€” allocate (do not allocate) any dynamically allocated data in CUDA Pinned host memory.
    • ptxinfo โ€” print ptxas information.
    • rdc (default), nordc โ€” generate (do not generate) relocatable device code for separate compilation, and invoke the device linker before the host linker at the link step.
    • redundant โ€” run accelerated code redundantly on CPU. Implied by autocompare.
    • safecache โ€” allow variable-sized array sections in cache directives; compiler assumes they fit into CUDA shared memory.
    • sm_XY โ€” generate code for a device with compute capability XY. Multiple compute capabilities can be specified, and one version will be generated for each. By default, the compiler will detect the compute capability for each installed GPU. Use -help -gpu to see the valid compute capabilities for your installation.
    • stacklimit:limit (default), nostacklimit โ€” this option has been deprecated and will be removed in a future release. Give an error if the total stack size of a kernel or procedure exceeds limit KBytes. The default is stacklimit:512. ๐Ÿ˜ญ
    • tripcount:host โ€” calculate loop trip counts on the host for some compute constructs. This is the default behavior when -gpu=tripcount is not specified. Note that this behavior is not compliant with the OpenACC specification. To ensure compliance with the specification, please use -gpu=tripcount:device.
    • tripcount:device โ€” calculate loop trip counts on the device for some compute constructs. Note that this behavior is compliant with the OpenACC specification, though it is not the default behavior. To explicitly enable the default behavior, please use -gpu=tripcount:host.
    • tripcount:warn, tripcount:nowarn โ€” enable (disable) compile-time warnings when loop trip counts are calculated on the host instead of on the device.
    • tripcount:check, tripcount:nocheck โ€” insert (do not insert) runtime checks to ensure the trip count value calculated on the device matches the trip count value calculated on the host. To enable reporting of differences, set the environment variable NVCOMPILER_ACC_CHECK_TRIPCOUNT. โœจ
  • unified โ€” compile for CUDA Unified memory capability, where system memory is accessible from the GPU. All variables in the CPU code are accessible from the GPU without explicit directives or attributes. This mode utilizes system and managed memory for dynamically allocated data unless explicit behavior is set through -gpu=[no]managed. This option must appear in both the compile and link lines. This option may not be used with -gpu=pinned. ๐Ÿ’…
    • intercept โ€” intercept LIBC function calls (e.g. free) and call their unified version if the address is in unified memory, regular version otherwise.
  • unroll, nounroll โ€” automatically (do not) unroll inner loops. This is enabled by default at optimization level -O3.
  • -Kieee, -Knoieee (default) โ€” perform floating-point operations in strict conformance with the IEEE 754 standard. Some optimizations are disabled with -Kieee, and a more accurate math library is used. The default -Knoieee uses faster but very slightly less accurate methods.
  • -Ktrap=option[,option]... โ€” controls the behavior of the processor when floating-point exceptions occur during program execution. Possible options include:
    • denorm โ€” trap on denormalized operands.
    • divz โ€” trap on divide by zero.
    • fp โ€” trap on floating-point exceptions.
    • inexact โ€” trap on inexact result.
    • inv โ€” trap on invalid operation.
    • none (default) โ€” disable all traps. -Ktrap=inv,none,ovf implies -Ktrap=ovf.
    • ovf โ€” trap on floating-point overflow.
    • unf โ€” trap on floating-point underflow. (-Ktrap is only meaningful when compiling a C/C++ main function or Fortran main program.)

-Ktrap=fp is shorthand for -Ktrap=divz,inv,ovf.

These options correspond to the processor's floating-point exception mask bits. Normally, the processor's exception mask bits are enabled, meaning floating-point exceptions are masked; the processor recovers from the exception and continues execution. If a mask bit is off (unmasked) and the corresponding exception occurs, execution terminates with a floating-point exception (Linux FPE signal). ๐Ÿ˜ญ

  • -march=target โ€” this option is the same as -tp. Please refer to -tp for details.
  • -m[no-]daz-ftz โ€” specify how denormals are handled by the processor at runtime. -mno-daz-ftz specifies that denormal operands and results are honored. Shorthand for -Mnodaz -Mnoflushz. -mdaz-ftz is the default setting and specifies that denormal operands and results are treated as zero. Shorthand for -Mdaz -Mflushz.
  • -Mdaz, -Mnodaz โ€” enable [disable] mode to treat denormal (subnormal) floating-point operands as zero. -Mdaz is the default setting for x86_64 and aarch64 processors.
  • -Mflushz, -Mnoflushz โ€” enable [disable] setting floating-point denormal (subnormal) results to zero; -Mflushz is the default setting for x86_64 and aarch64 processors.
  • -Mfpmisalign, -Mnofpmisalign โ€” allow (don't allow) vector arithmetic instructions with memory operands that are not aligned on 16-byte boundaries.
  • -Mfprelaxed [=option[,option,...]], -Mnofprelaxed (default) โ€” perform (don't perform) certain floating-point operations using relaxed precision when it improves speed. The options are:
    • div โ€” perform divide using relaxed precision.
    • intrinsic โ€” perform certain intrinsic functions using relaxed precision.
    • order, noorder โ€” allow (don't allow) expression reordering, including factoring such as computing a*b+a*c as a*(b+c).
    • recip โ€” perform reciprocal operations using relaxed precision.
    • rsqrt โ€” perform reciprocal square root (1/sqrt) using relaxed precision.
    • sqrt โ€” perform square root using relaxed precision.

With no options, -Mfprelaxed will choose to generate relaxed precision code for those operations that generate a significant performance improvement, depending on the target processor. โœจ

  • -Mfunc32 (default), -Mnofunc32 โ€” align (don't align) functions on 32 byte boundaries.
  • -Mgccbugs โ€” match the behavior of certain bugs in gcc.
  • -Mlongbranch, -Mnolongbranch (default) โ€” enable (disable) long branches.
  • -Msecond_underscore, -Mnosecond_underscore (default) โ€” add (don't add) a second underscore to the name of a Fortran global if its name already contains an underscore. This option is useful for maintaining compatibility with g77, which adds a second underscore to such symbols by default.
  • -Mwritable-strings โ€” store string constants in the writable data segment.
  • -mcmodel=small|medium โ€” pick the memory model vibe:
    • small โ€” limits the combined area for a user's object or executable to 4GB. The maximum code size is 2GB.
    • medium โ€” allows unrestricted data size. The maximum code size is 2GB.
  • -ta=target โ€” this option has been deprecated please refer to -acc. ๐Ÿซ 
    • -ta=tesla โ€” this option has been deprecated please refer to -acc=gpu and -gpu.
    • -ta=multicore โ€” this option has been deprecated please refer to -acc=multicore.
    • -ta=host โ€” this option has been deprecated please refer to -acc=host.
  • -target=option โ€” select the target for all parallel programming paradigms used (OpenACC, OpenMP, Standard Languages); possibilities are:
    • gpu โ€” globally set the target device to an NVIDIA GPU.
    • multicore โ€” globally set the target device to the host CPU.
  • -tp=target โ€” specify the type of the target processor. Issue:
nvc -help -tp

to display the list of recognized target processors. ๐Ÿ‘‘


๐Ÿ—‚๏ธ FILES ๐Ÿ—‚๏ธ

  • a.out โ€” executable output file
  • file.a โ€” library of object files
  • file.c โ€” C source file
  • file.i โ€” C source file after preprocessing
  • file.ipa โ€” InterProcedural Analyzer (IPA) file
  • file.ipo โ€” InterProcedural Analyzer (IPA) file
  • file.o โ€” object file
  • file.s โ€” assembler source file
  • .mynvcrc โ€” you may add custom switches or make other additions to nvc by creating a file named .mynvcrc in your home directory.

The installation of this version of the compiler resides in Basedir/Linux_x86_64/dev/; other versions may coexist in Basedir/Linux_x86_64/release/. Basedir is the root of the compiler installation directory, specified by the installer. The default is /opt/nvidia/hpc_sdk. ๐Ÿ’พ

The compiler installation subdirectories are:

  • compilers/bin/ โ€” compiler and tool executables and configuration files (rcfiles).
  • compilers/include/ โ€” compiler include files.
  • compilers/lib/ โ€” runtime libraries and object files.
  • comm_libs/ โ€” communication libraries, including NCCL and NVSHMEM.
  • math_libs/ โ€” math libraries, including cuBLAS, cuTENSOR, cuSPARSE, cuFFT, cuSOLVER, and cuRAND.
  • profilers/ โ€” profilers, including Nsight Compute and Nsight Systems.

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

nvc++ (1), nvfortran (1), and the NVIDIA User's Guide.


๐Ÿฉบ DIAGNOSTICS ๐Ÿฉบ

The compiler produces information and error messages as it translates the input program. The linker and assembler may issue their own error messages.


That's the whole nvc(1) page, bestie โ€” catch you in the September 2026 edition of nvc(1) ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from