linux.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. elif env["use_hot_reload"]:
  12. # Required for extensions to truly unload.
  13. env.Append(CXXFLAGS=["-fno-gnu-unique"])
  14. env.Append(CCFLAGS=["-fPIC", "-Wwrite-strings"])
  15. env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
  16. if env["arch"] == "x86_64":
  17. # -m64 and -m32 are x86-specific already, but it doesn't hurt to
  18. # be clear and also specify -march=x86-64. Similar with 32-bit.
  19. env.Append(CCFLAGS=["-m64", "-march=x86-64"])
  20. env.Append(LINKFLAGS=["-m64", "-march=x86-64"])
  21. elif env["arch"] == "x86_32":
  22. env.Append(CCFLAGS=["-m32", "-march=i686"])
  23. env.Append(LINKFLAGS=["-m32", "-march=i686"])
  24. elif env["arch"] == "arm64":
  25. env.Append(CCFLAGS=["-march=armv8-a"])
  26. env.Append(LINKFLAGS=["-march=armv8-a"])
  27. elif env["arch"] == "rv64":
  28. env.Append(CCFLAGS=["-march=rv64gc"])
  29. env.Append(LINKFLAGS=["-march=rv64gc"])
  30. env.Append(CPPDEFINES=["LINUX_ENABLED", "UNIX_ENABLED"])