fab icon indicating copy to clipboard operation
fab copied to clipboard

Compiler selection flags

Open t00sa opened this issue 4 months ago • 2 comments

After a design discussion with @MatthewHambley, we think the front-end command would benefit from command line options to set the compiler(s) with the de facto standard $CC, $CXX, and $FC environment variables used as defaults if they are set.

t00sa avatar Aug 14 '25 15:08 t00sa

You should also add an option to add a compiler suite, e.g. allow a user to just specify: "I want intel-llvm" (or gnu), Fab can then select the right set of tools.

Re $CXX: does Fab actually support C++?

    config.artefact_store.copy_artefacts(output_collection,
                                         ArtefactSet.C_BUILD_FILES,
                                         suffixes=[".c"])

That would not support any .cpp or .cxx files (often used ending).

You should also support environment variables for compiler flags then.

Can I contribute?

        parser.add_argument(
            '--fc', '-fc', type=str, default="$FC",
            help="Name of the Fortran compiler to use")
        parser.add_argument(
            '--cc', '-cc', type=str, default="$CC",
            help="Name of the C compiler to use")
        parser.add_argument(
            '--ld', '-ld', type=str, default="$LD",
            help="Name of the linker to use")
        parser.add_argument(
            '--fflags', '-fflags', type=str, default=None,
            help="Flags to be used by the Fortran compiler. The command line "
                 "flags are appended after compiler flags defined in a "
                 "site-specific setup and after getting flags from the "
                 "environment variable $FFLAGS. Therefore, this can be used "
                 "to overwrite certain flags.")
        parser.add_argument(
            '--cflags', '-cflags', type=str, default=None,
            help="Flags to be used by the C compiler. The command line "
                 "flags are appended after compiler flags defined in a "
                 "site-specific setup and after getting flags from the "
                 "environment variable $CFLAGS. Therefore, this can be used "
                 "to overwrite certain flags.")
        parser.add_argument(
            '--ldflags', '-ldflags', type=str, default=None,
            help="Flags to be used by the linker. The command line "
                 "flags are appended after linker flags defined in a "
                 "site-specific setup and after getting flags from the "
                 "environment variable $LDFLAGS. Therefore, this can be used "
                 "to overwrite certain flags.")

...
            # If no suite is specified, if required set the defaults
            # for compilers based on the environment variables.
            if self.args.fc == "$FC":
                self.args.fc = os.environ.get("FC")
            if self.args.cc == "$CC":
                self.args.cc = os.environ.get("CC")
            if self.args.ld == "$LD":
                self.args.ld = os.environ.get("LD")
...

There's more of course.

Hang on, this is PR #414. @yaswant, should we close this ticket as duplicate?

hiker avatar Aug 15 '25 07:08 hiker

@hiker this is a parallel development - let's discuss in the next meet.

yaswant avatar Aug 15 '25 15:08 yaswant