How do I forbid avx512 while compile a program with -static option?

124 views Asked by At

I have a program that can compile at local machine and need to run at remote server, and it's not allowed to be compiled at remote server.

Now cpus of these local machine all have AVX512 instruments set, but remote server doesn't. Generally speaking, we can use -march=x86-86, -march=core-avx2, -mo-avx512f etc. to try to forbidden avx512 instrument, but there is a problem is that, the version of glibc at local machine is higher than remote, so I need to compile the program statically. If not, program will dump at remote server because glibc's version is not lower(and it's not allowed to update the glibc at remote server too,sadly), but when I compile with -static, I will find that the program have AVX512 instruments. (the way i find AVX512 is to use a tool named elfx86exts to check what instrument the program have).

Is there some ways to compile a program that be able to run at remote server?

I'm sorry that my English is not so well, if there is some points that I didn't express clearly, please ask me.Thank you all.

I tried some compile option combinations.

  1. -static -march=x86-64.
  2. + -mno-avx512f -mno-avx512dq -mno-avx512idma and other -mno-avx512** options.
  3. -static-libgcc -static-libstdc++ -march=x86-64
  4. -march=x86-64. -mno-avx512**

1,2,3 will fail at the ci of avx512 test, 4 has no avx512, but will have conflict of version of glibc.

1

There are 1 answers

2
Employed Russian On

but there is a problem is that, the version of glibc at local machine is higher than remote, so I need to compile the program statically.

The solution to this problem is not to link statically; it is to link against appropriate for the target version of libc (e.g. by building inside a docker container, or by pointing the compiler at an alternate libc installation).

Contrary to popular belief, statically-linked binaries almost never work (correctly) when moved to a different machine.