22 lines
993 B
Python
22 lines
993 B
Python
import sys
|
|
import os
|
|
|
|
assert len(sys.argv) > 3
|
|
print("compile {}".format(sys.argv[2]))
|
|
selector = sys.argv[1]
|
|
fullpath = sys.argv[2]
|
|
libpath = sys.argv[3]
|
|
(filename, extname) = os.path.splitext(fullpath)
|
|
'''
|
|
python3 my|clang scripts/manual-compile.py build/manual-test/55_sort_test1.sy tools/sylib/libsysy_x86.a
|
|
'''
|
|
# os.system(f"clang -emit-llvm -S {fullpath} -o {filename}.ll -O0 -fno-builtin")
|
|
if selector != "my":
|
|
print(f"clang -x c -c -m32 -emit-llvm -S {fullpath} -o {filename}.ll -O0 -fno-builtin")
|
|
os.system(f"clang -x c -c -m32 -emit-llvm -S {fullpath} -o {filename}.ll -O0 -fno-builtin")
|
|
print(f"llc --march=x86 --relocation-model=pic {filename}.ll -o {filename}.s")
|
|
os.system(f"llc --march=x86 --relocation-model=pic {filename}.ll -o {filename}.s")
|
|
print(f"as --32 {filename}.s -o {filename}.o")
|
|
os.system(f"as --32 {filename}.s -o {filename}.o")
|
|
print(f"clang -m32 -fPIE {filename}.o {libpath} -o {filename}")
|
|
os.system(f"clang -m32 -fPIE {filename}.o {libpath} -o {filename}") |