6. Mercurium Legacy Compiler Options


Mercurium is the OmpSs-2 legacy compiler and is unsupported now. We recommend to use the LLVM-based compiler instead. Check LLVM-based compiler.

This section describes how to use the legacy Mercurium compiler to compile OmpSs-2 programs.

6.1. Mercurium drivers

The list of available drivers can be found here: https://github.com/bsc-pm/mcxx/blob/master/doc/md_pages/profiles.md

6.2. Common compilation flags

Usual flags like -O, -O1, -O2, -O3, -D, -c, -o, … are recognized by Mercurium.

Almost every Mercurium-specific flag is of the form --xxx.

Mercurium drivers are deliberately compatible with gcc. This means that flags of the form -fXXX, -mXXX and -Wxxx are accepted and passed onto the backend compiler without interpretation by Mercurium drivers.


In GCC a flag of the form -fXXX is equivalent to a flag of the form --XXX. This is not the case in Mercurium.

6.2.1. Getting command line help

You can get a summary of all the flags accepted by Mercurium using --help with any of the drivers:

$ mcc --help
Usage: mcc options file [file..]
  -h, --help               Shows this help and quits
  --version                Shows version and quits
  --v, --verbose           Runs verbosely, displaying the programs
                           invoked by the compiler

6.2.2. Passing vendor-specific flags

While almost every gcc of the form -fXXX or -mXXX can be passed directly to a Mercurium driver, some other vendor-specific flags may not be well known or be misunderstood by Mercurium. When this happens, Mercurium has a generic way to pass parameters to the backend compiler and linker.


Passes comma-separated flags to the native compiler. These flags are used when Mercurium invokes the backend compiler to generate the object file (.o)


Passes comma-separated-flags to the linker. These flags are used when Mercurium invokes the linker


Passes comma-separated flags to the C/Fortran preprocessor. These flags are used when Mercurium invokes the preprocessor on a C or Fortran file.

These flags can be combined. Flags --Wp,a --Wp,b are equivalent to --Wp,a,b. Flag --Wnp,a is equivalent to --Wn,a --Wp,a


Do not confuse --Wl and --Wp with the gcc similar flags -Wl and -Wp (note that gcc ones have a single -). The latter can be used with the former, as in --Wl,-Wl,muldefs. That said, Mercurium supports -Wl and -Wp directly, so -Wl,muldefs should be enough.

6.3. Compile OmpSs-2 programs

For OmpSs-2 programs that run in SMP or NUMA systems, you do not have to do anything. Just pick one of the drivers above.

Following is a very simple OmpSs-2 program in C:

/* test.c */
#include <stdio.h>

int main(int argc, char *argv[])
  int x = argc;
  #pragma oss task inout(x)
  #pragma oss task in(x)
    printf("argc + 1 == %d\n", x);
  #pragma oss taskwait
  return 0;

Compile it using mcc:

$ mcc -o test --ompss-2 test.c


Do not forget the flag --ompss-2 otherwise your program will be compiled without parallel support.

And run it:

$ ./test
argc + 1 == 2

6.3.1. Compile OpenMP programs with OmpSs-2 support

By passing the --openmp-compatibility flag, Mercurium will support some constructs of OpenMP (e.g. taskloop, parallel for, etc.).


Experimental flag. There are no guarantees the generated code behaves as the OpenMP program.

6.4. Problems during compilation

While we put big efforts to make a reasonably robust compiler, you may encounter a bug or problem with Mercurium.

There are several errors of different nature that you may run into:

  • Mercurium ends abnormally with an internal error telling you to open a ticket.

  • Mercurium does not crash but gives an error on your input code and compilation stops, as if your code were not valid.

  • Mercurium does not crash, but gives an error involving an internal-source.

  • Mercurium generates wrong code and native compilation fails on an intermediate file.

  • Mercurium forgets something in the generated code and linking fails.

6.4.1. How can you help us to solve the problem quicker?

In order for us to fix your problem we need the preprocessed file. If your program is C/C++ we need you to do:

  1. Figure out the compilation command of the file that fails to compile. Make sure you can replicate the problem using that compilation command alone.

  2. If your compilation command includes -c, replace it by -E. If it does not include -c simply add -E.

  3. If your compilation command includes -o file (or -o file.o) replace it by -o file.ii. If it does not include -o, simply add -o file.ii.

  4. Now run the compiler with this modified compilation command. It should have generated a file.ii.

  5. These files are usually very large. Please compress them with gzip (or bzip2 or any similar tool).

Send us an email to pm-tools at bsc.es with the error message you are experiencing and the (compressed) preprocessed file attached. If your program is Fortran just the input file may be enough, but you may have to add all the INCLUDEd files and modules.