2
0

linux.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. from SCons.Variables import *
  2. from SCons.Tool import clang, clangxx
  3. def options(opts):
  4. opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler - only effective when targeting Linux", False))
  5. def exists(env):
  6. return True
  7. def generate(env):
  8. if env["use_llvm"]:
  9. clang.generate(env)
  10. clangxx.generate(env)
  11. env.Append(CCFLAGS=["-fPIC", "-Wwrite-strings"])
  12. env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
  13. if env["arch"] == "x86_64":
  14. # -m64 and -m32 are x86-specific already, but it doesn't hurt to
  15. # be clear and also specify -march=x86-64. Similar with 32-bit.
  16. env.Append(CCFLAGS=["-m64", "-march=x86-64"])
  17. env.Append(LINKFLAGS=["-m64", "-march=x86-64"])
  18. elif env["arch"] == "x86_32":
  19. env.Append(CCFLAGS=["-m32", "-march=i686"])
  20. env.Append(LINKFLAGS=["-m32", "-march=i686"])
  21. elif env["arch"] == "arm64":
  22. env.Append(CCFLAGS=["-march=armv8-a"])
  23. env.Append(LINKFLAGS=["-march=armv8-a"])
  24. elif env["arch"] == "rv64":
  25. env.Append(CCFLAGS=["-march=rv64gc"])
  26. env.Append(LINKFLAGS=["-march=rv64gc"])