makefile 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #CXX=g++-8
  2. #CC=gcc-8
  3. AR=gcc-ar
  4. PLATFORM=$(shell uname -m)
  5. OS=$(shell uname -s)
  6. CXXFLAGS=-std=c++11
  7. CCFLAGS=-std=c99
  8. ARFLAGS=rcs
  9. BINDIR=bin
  10. SRCDIR=src
  11. TESTDIR=src/tests
  12. OBJDIR=obj
  13. LDFLAGS=-lpthread
  14. RXA=$(BINDIR)/librandomx.a
  15. BINARIES=$(RXA) $(BINDIR)/randomx-benchmark $(BINDIR)/randomx-generator $(BINDIR)/randomx-tests
  16. RXOBJS=$(addprefix $(OBJDIR)/,aes_hash.o argon2_ref.o bytecode_machine.o dataset.o soft_aes.o virtual_memory.o vm_interpreted.o allocator.o assembly_generator_x86.o instruction.o randomx.o superscalar.o vm_compiled.o vm_interpreted_light.o argon2_core.o blake2_generator.o instructions_portable.o reciprocal.o virtual_machine.o vm_compiled_light.o blake2b.o)
  17. ifeq ($(PLATFORM),amd64)
  18. RXOBJS += $(addprefix $(OBJDIR)/,jit_compiler_x86_static.o jit_compiler_x86.o)
  19. CXXFLAGS += -maes
  20. endif
  21. ifeq ($(PLATFORM),x86_64)
  22. RXOBJS += $(addprefix $(OBJDIR)/,jit_compiler_x86_static.o jit_compiler_x86.o)
  23. CXXFLAGS += -maes
  24. endif
  25. ifeq ($(OS),Darwin)
  26. AR=ar
  27. endif
  28. ifeq ($(PLATFORM),ppc64)
  29. CXXFLAGS += -mcpu=native
  30. endif
  31. ifeq ($(PLATFORM),ppc64le)
  32. CXXFLAGS += -mcpu=native
  33. endif
  34. release: CXXFLAGS += -O3 -flto
  35. release: CCFLAGS += -O3 -flto
  36. release: LDFLAGS += -flto
  37. release: $(BINARIES)
  38. native: CXXFLAGS += -march=native -O3 -flto
  39. native: CCFLAGS += -march=native -O3 -flto
  40. native: $(BINARIES)
  41. nolto: CXXFLAGS += -O3
  42. nolto: CCFLAGS += -O3
  43. nolto: $(BINARIES)
  44. debug: CXXFLAGS += -g
  45. debug: CCFLAGS += -g
  46. debug: LDFLAGS += -g
  47. debug: $(BINARIES)
  48. profile: CXXFLAGS += -pg
  49. profile: CCFLAGS += -pg
  50. profile: LDFLAGS += -pg
  51. profile: $(BINDIR)/randomx-benchmark
  52. test: CXXFLAGS += -O0
  53. $(RXA): $(RXOBJS) | $(BINDIR)
  54. $(AR) $(ARFLAGS) $@ $(RXOBJS)
  55. $(OBJDIR):
  56. mkdir $(OBJDIR)
  57. $(BINDIR):
  58. mkdir $(BINDIR)
  59. $(OBJDIR)/affinity.o: $(TESTDIR)/affinity.cpp $(TESTDIR)/affinity.hpp
  60. $(CXX) $(CXXFLAGS) -c $< -o $@
  61. $(OBJDIR)/benchmark.o: $(TESTDIR)/benchmark.cpp $(TESTDIR)/stopwatch.hpp \
  62. $(TESTDIR)/utility.hpp $(SRCDIR)/randomx.h $(SRCDIR)/blake2/endian.h $(TESTDIR)/affinity.hpp
  63. $(CXX) $(CXXFLAGS) -pthread -c $< -o $@
  64. $(BINDIR)/randomx-benchmark: $(OBJDIR)/benchmark.o $(OBJDIR)/affinity.o $(RXA)
  65. $(CXX) $(LDFLAGS) -pthread $< $(OBJDIR)/affinity.o $(RXA) -o $@
  66. $(OBJDIR)/code-generator.o: $(TESTDIR)/code-generator.cpp $(TESTDIR)/utility.hpp \
  67. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  68. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  69. $(SRCDIR)/assembly_generator_x86.hpp $(SRCDIR)/superscalar.hpp \
  70. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/instruction.hpp \
  71. $(SRCDIR)/blake2_generator.hpp $(SRCDIR)/aes_hash.hpp \
  72. $(SRCDIR)/blake2/blake2.h $(SRCDIR)/program.hpp
  73. $(CXX) $(CXXFLAGS) -c $< -o $@
  74. $(BINDIR)/randomx-generator: $(OBJDIR)/code-generator.o $(RXA)
  75. $(CXX) $(LDFLAGS) $< $(RXA) -o $@
  76. $(OBJDIR)/tests.o: $(TESTDIR)/tests.cpp $(TESTDIR)/utility.hpp \
  77. $(SRCDIR)/bytecode_machine.hpp $(SRCDIR)/common.hpp \
  78. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h \
  79. $(SRCDIR)/randomx.h $(SRCDIR)/intrin_portable.h \
  80. $(SRCDIR)/instruction.hpp $(SRCDIR)/program.hpp \
  81. $(SRCDIR)/dataset.hpp $(SRCDIR)/superscalar_program.hpp \
  82. $(SRCDIR)/allocator.hpp $(SRCDIR)/blake2/blake2.h \
  83. $(SRCDIR)/blake2_generator.hpp $(SRCDIR)/superscalar.hpp \
  84. $(SRCDIR)/reciprocal.h $(SRCDIR)/jit_compiler.hpp \
  85. $(SRCDIR)/jit_compiler_x86.hpp
  86. $(CXX) $(CXXFLAGS) -c $< -o $@
  87. $(BINDIR)/randomx-tests: $(OBJDIR)/tests.o $(RXA)
  88. $(CXX) $(LDFLAGS) $< $(RXA) -o $@
  89. $(OBJDIR)/aes_hash.o: $(SRCDIR)/aes_hash.cpp $(SRCDIR)/soft_aes.h $(SRCDIR)/intrin_portable.h | $(OBJDIR)
  90. $(OBJDIR)/argon2_ref.o: $(SRCDIR)/argon2_ref.c $(SRCDIR)/argon2.h $(SRCDIR)/argon2_core.h \
  91. $(SRCDIR)/blake2/blamka-round-ref.h $(SRCDIR)/blake2/blake2.h \
  92. $(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h $(SRCDIR)/blake2/blake2-impl.h \
  93. $(SRCDIR)/blake2/blake2.h
  94. $(OBJDIR)/bytecode_machine.o: $(SRCDIR)/bytecode_machine.cpp $(SRCDIR)/bytecode_machine.hpp \
  95. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  96. $(SRCDIR)/intrin_portable.h $(SRCDIR)/instruction.hpp $(SRCDIR)/program.hpp \
  97. $(SRCDIR)/reciprocal.h
  98. $(OBJDIR)/blake2b.o: $(SRCDIR)/blake2/blake2b.c $(SRCDIR)/blake2/blake2.h \
  99. $(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h
  100. $(CC) $(CCFLAGS) -c $< -o $@
  101. $(OBJDIR)/dataset.o: $(SRCDIR)/dataset.cpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  102. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/dataset.hpp \
  103. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/jit_compiler_x86.hpp \
  104. $(SRCDIR)/allocator.hpp $(SRCDIR)/virtual_memory.hpp $(SRCDIR)/superscalar.hpp \
  105. $(SRCDIR)/blake2_generator.hpp $(SRCDIR)/reciprocal.h $(SRCDIR)/argon2.h $(SRCDIR)/argon2_core.h \
  106. $(SRCDIR)/intrin_portable.h
  107. $(OBJDIR)/jit_compiler_x86.o: $(SRCDIR)/jit_compiler_x86.cpp $(SRCDIR)/jit_compiler_x86.hpp \
  108. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  109. $(SRCDIR)/jit_compiler_x86_static.hpp $(SRCDIR)/superscalar.hpp \
  110. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/blake2_generator.hpp \
  111. $(SRCDIR)/program.hpp $(SRCDIR)/reciprocal.h $(SRCDIR)/virtual_memory.hpp \
  112. $(SRCDIR)/instruction_weights.hpp
  113. $(OBJDIR)/jit_compiler_x86_static.o: $(SRCDIR)/jit_compiler_x86_static.S $(SRCDIR)/configuration.h \
  114. $(SRCDIR)/asm/program_prologue_linux.inc $(SRCDIR)/asm/program_xmm_constants.inc \
  115. $(SRCDIR)/asm/program_loop_load.inc $(SRCDIR)/asm/program_read_dataset.inc \
  116. $(SRCDIR)/asm/program_read_dataset_sshash_init.inc \
  117. $(SRCDIR)/asm/program_read_dataset_sshash_fin.inc \
  118. $(SRCDIR)/asm/program_loop_store.inc $(SRCDIR)/asm/program_epilogue_linux.inc \
  119. $(SRCDIR)/asm/program_epilogue_store.inc $(SRCDIR)/asm/program_sshash_load.inc \
  120. $(SRCDIR)/asm/program_sshash_prefetch.inc $(SRCDIR)/asm/program_sshash_constants.inc \
  121. $(SRCDIR)/asm/randomx_reciprocal.inc
  122. $(OBJDIR)/soft_aes.o: $(SRCDIR)/soft_aes.cpp $(SRCDIR)/soft_aes.h $(SRCDIR)/intrin_portable.h
  123. $(OBJDIR)/virtual_memory.o: $(SRCDIR)/virtual_memory.cpp $(SRCDIR)/virtual_memory.hpp
  124. $(OBJDIR)/vm_interpreted.o: $(SRCDIR)/vm_interpreted.cpp $(SRCDIR)/vm_interpreted.hpp \
  125. $(SRCDIR)/bytecode_machine.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  126. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/virtual_machine.hpp \
  127. $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/instruction_weights.hpp \
  128. $(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
  129. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/reciprocal.h
  130. $(OBJDIR)/allocator.o: $(SRCDIR)/allocator.cpp $(SRCDIR)/allocator.hpp $(SRCDIR)/intrin_portable.h \
  131. $(SRCDIR)/virtual_memory.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  132. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h
  133. $(OBJDIR)/assembly_generator_x86.o: $(SRCDIR)/assembly_generator_x86.cpp \
  134. $(SRCDIR)/assembly_generator_x86.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  135. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/reciprocal.h $(SRCDIR)/program.hpp \
  136. $(SRCDIR)/instruction.hpp $(SRCDIR)/superscalar.hpp $(SRCDIR)/superscalar_program.hpp \
  137. $(SRCDIR)/blake2_generator.hpp $(SRCDIR)/instruction_weights.hpp
  138. $(OBJDIR)/instruction.o: $(SRCDIR)/instruction.cpp $(SRCDIR)/instruction.hpp \
  139. $(SRCDIR)/blake2/endian.h $(SRCDIR)/common.hpp $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  140. $(SRCDIR)/instruction_weights.hpp
  141. $(OBJDIR)/randomx.o: $(SRCDIR)/randomx.cpp $(SRCDIR)/randomx.h $(SRCDIR)/dataset.hpp $(SRCDIR)/common.hpp \
  142. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/superscalar_program.hpp \
  143. $(SRCDIR)/instruction.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/allocator.hpp \
  144. $(SRCDIR)/vm_interpreted.hpp $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp \
  145. $(SRCDIR)/intrin_portable.h $(SRCDIR)/vm_interpreted_light.hpp $(SRCDIR)/vm_compiled.hpp \
  146. $(SRCDIR)/vm_compiled_light.hpp $(SRCDIR)/blake2/blake2.h $(SRCDIR)/bytecode_machine.hpp
  147. $(OBJDIR)/superscalar.o: $(SRCDIR)/superscalar.cpp $(SRCDIR)/configuration.h $(SRCDIR)/program.hpp \
  148. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/randomx.h $(SRCDIR)/instruction.hpp \
  149. $(SRCDIR)/superscalar.hpp $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/blake2_generator.hpp \
  150. $(SRCDIR)/intrin_portable.h $(SRCDIR)/reciprocal.h
  151. $(OBJDIR)/vm_compiled.o: $(SRCDIR)/vm_compiled.cpp $(SRCDIR)/vm_compiled.hpp \
  152. $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h \
  153. $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp \
  154. $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
  155. $(SRCDIR)/superscalar_program.hpp
  156. $(OBJDIR)/vm_interpreted_light.o: $(SRCDIR)/vm_interpreted_light.cpp \
  157. $(SRCDIR)/vm_interpreted_light.hpp $(SRCDIR)/vm_interpreted.hpp $(SRCDIR)/common.hpp \
  158. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  159. $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp \
  160. $(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp $(SRCDIR)/dataset.hpp \
  161. $(SRCDIR)/superscalar_program.hpp $(SRCDIR)/jit_compiler_x86.hpp \
  162. $(SRCDIR)/bytecode_machine.hpp
  163. $(OBJDIR)/argon2_core.o: $(SRCDIR)/argon2_core.c $(SRCDIR)/argon2_core.h $(SRCDIR)/argon2.h \
  164. $(SRCDIR)/blake2/blake2.h $(SRCDIR)/blake2/blake2-impl.h $(SRCDIR)/blake2/endian.h
  165. $(OBJDIR)/blake2_generator.o: $(SRCDIR)/blake2_generator.cpp $(SRCDIR)/blake2/blake2.h \
  166. $(SRCDIR)/blake2/endian.h $(SRCDIR)/blake2_generator.hpp
  167. $(OBJDIR)/instructions_portable.o: $(SRCDIR)/instructions_portable.cpp $(SRCDIR)/common.hpp \
  168. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  169. $(SRCDIR)/intrin_portable.h
  170. $(OBJDIR)/reciprocal.o: $(SRCDIR)/reciprocal.c $(SRCDIR)/reciprocal.h
  171. $(OBJDIR)/virtual_machine.o: $(SRCDIR)/virtual_machine.cpp $(SRCDIR)/virtual_machine.hpp \
  172. $(SRCDIR)/common.hpp $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h \
  173. $(SRCDIR)/program.hpp $(SRCDIR)/instruction.hpp $(SRCDIR)/aes_hash.hpp $(SRCDIR)/blake2/blake2.h \
  174. $(SRCDIR)/intrin_portable.h $(SRCDIR)/allocator.hpp
  175. $(OBJDIR)/vm_compiled_light.o: $(SRCDIR)/vm_compiled_light.cpp $(SRCDIR)/vm_compiled_light.hpp \
  176. $(SRCDIR)/vm_compiled.hpp $(SRCDIR)/virtual_machine.hpp $(SRCDIR)/common.hpp \
  177. $(SRCDIR)/blake2/endian.h $(SRCDIR)/configuration.h $(SRCDIR)/randomx.h $(SRCDIR)/program.hpp \
  178. $(SRCDIR)/instruction.hpp $(SRCDIR)/jit_compiler_x86.hpp $(SRCDIR)/allocator.hpp \
  179. $(SRCDIR)/dataset.hpp $(SRCDIR)/superscalar_program.hpp
  180. $(OBJDIR)/%.o: $(SRCDIR)/%.c
  181. $(CC) $(CCFLAGS) -c $< -o $@
  182. $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
  183. $(CXX) $(CXXFLAGS) -c $< -o $@
  184. $(OBJDIR)/%.o: $(SRCDIR)/%.S
  185. $(CXX) -x assembler-with-cpp -c $< -o $@
  186. clean:
  187. rm -f $(BINARIES) $(OBJDIR)/*.o