linux.py 1.2 KB

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