Skip to content

Commit a025cf4

Browse files
authored
Merge pull request #1576 from clasp-developers/cli
Misc updates
2 parents 66bdd6f + 3f21892 commit a025cf4

File tree

10 files changed

+102
-19
lines changed

10 files changed

+102
-19
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- clasp
2222
- cando
2323
os:
24-
- macos-latest
24+
- macos-13
2525
- ubuntu-latest
2626
mode:
2727
- faso
@@ -41,9 +41,9 @@ jobs:
4141
auto: yes
4242
- mode: bytecode-faso
4343
auto: yes
44-
- os: macos-latest
44+
- os: macos-13
4545
mode: faso
46-
- os: macos-latest
46+
- os: macos-13
4747
mode: bytecode
4848
auto: no
4949

@@ -57,15 +57,15 @@ jobs:
5757
sudo apt install -y binutils-gold clang-15 libclang-15-dev libclang-cpp15-dev llvm-15 llvm-15-dev libelf-dev libgmp-dev libunwind-dev ninja-build sbcl libnetcdf-dev libexpat1-dev libfmt-dev libboost-all-dev
5858
5959
- name: Install MacOS dependencies
60-
if: matrix.os == 'macos-latest'
60+
if: matrix.os == 'macos-13'
6161
run: |
6262
brew update
6363
brew upgrade
64-
brew install boost fmt gmp llvm@17 ninja pkg-config sbcl netcdf
64+
brew install boost fmt gmp llvm ninja pkg-config sbcl netcdf
6565
- name: Checkout repository
6666
uses: actions/checkout@v4
6767

68-
- uses: conda-incubator/setup-miniconda@v3.0.1
68+
- uses: conda-incubator/setup-miniconda@v3.0.4
6969
if: matrix.build == 'cando'
7070

7171
- name: Install AmberTools
@@ -82,13 +82,13 @@ jobs:
8282
run: |
8383
./koga --build-mode=${{ matrix.mode }} --extensions=cando,seqan-clasp
8484
- name: Clasp koga @ MacOS
85-
if: ${{ matrix.os == 'macos-latest' && matrix.build == 'clasp' }}
85+
if: ${{ matrix.os == 'macos-13' && matrix.build == 'clasp' }}
8686
run: |
87-
./koga --build-mode=${{ matrix.mode }} --llvm-config=/usr/local/opt/llvm@15/bin/llvm-config
87+
./koga --build-mode=${{ matrix.mode }}
8888
- name: Cando koga @ MacOS
89-
if: ${{ matrix.os == 'macos-latest' && matrix.build == 'cando' }}
89+
if: ${{ matrix.os == 'macos-13' && matrix.build == 'cando' }}
9090
run: |
91-
./koga --build-mode=${{ matrix.mode }} --extensions=cando,seqan-clasp --llvm-config=/usr/local/opt/llvm@15/bin/llvm-config
91+
./koga --build-mode=${{ matrix.mode }} --extensions=cando,seqan-clasp
9292
- name: Build
9393
run: |
9494
ninja -C build

RELEASE_NOTES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Version 2.6.0 (LLVM15-18) Pending
2+
3+
## Added
4+
* LLVM18 support.
5+
6+
## Changed
7+
* Exit with error code when unknown option is present on command line.
8+
19
# Version 2.5.0 (LLVM15-17) 2024-01-01
210

311
## Added

include/clasp/llvmo/llvmoExpose.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ template <> struct to_object<const llvm::TargetSubtargetInfo*> {
711711
};
712712
}; // namespace translate
713713

714+
#if LLVM_VERSION_MAJOR < 18
714715
namespace translate {
715716
template <> struct from_object<llvm::CodeGenOpt::Level> {
716717
typedef llvm::CodeGenOpt::Level DeclareType;
@@ -727,6 +728,24 @@ template <> struct from_object<llvm::CodeGenOpt::Level> {
727728
}
728729
}
729730
};
731+
#else
732+
namespace translate {
733+
template <> struct from_object<llvm::CodeGenOptLevel> {
734+
typedef llvm::CodeGenOptLevel DeclareType;
735+
DeclareType _v;
736+
from_object(T_P object) : _v(llvm::CodeGenOptLevel::Default) {
737+
if (object.nilp()) {
738+
SIMPLE_ERROR("You must pass a valid CodeGenOpt");
739+
}
740+
if (core::Symbol_sp so = object.asOrNull<core::Symbol_O>()) {
741+
core::SymbolToEnumConverter_sp converter = gc::As<core::SymbolToEnumConverter_sp>(llvmo::_sym_CodeGenOpt->symbolValue());
742+
this->_v = converter->enumForSymbol<llvm::CodeGenOptLevel>(so);
743+
} else {
744+
SIMPLE_ERROR("You must pass a valid CodeGenOptLevel");
745+
}
746+
}
747+
};
748+
#endif
730749

731750
#if LLVM_VERSION_MAJOR < 16
732751
template <> struct from_object<llvm::Optional<llvm::Reloc::Model>> {
@@ -785,6 +804,7 @@ template <> struct from_object<llvm::CodeModel::Model> {
785804
}
786805
}
787806
};
807+
#if LLVM_VERSION_MAJOR < 18
788808
template <> struct from_object<llvm::CodeGenFileType> {
789809
typedef llvm::CodeGenFileType DeclareType;
790810
DeclareType _v;
@@ -800,6 +820,23 @@ template <> struct from_object<llvm::CodeGenFileType> {
800820
SIMPLE_ERROR("You must pass a valid ");
801821
}
802822
};
823+
#else
824+
template <> struct from_object<llvm::CodeGenFileType> {
825+
typedef llvm::CodeGenFileType DeclareType;
826+
DeclareType _v;
827+
from_object(T_P object) : _v(llvm::CodeGenFileType::ObjectFile) {
828+
if (object.notnilp()) {
829+
if (core::Symbol_sp so = object.asOrNull<core::Symbol_O>()) {
830+
core::SymbolToEnumConverter_sp converter =
831+
gc::As<core::SymbolToEnumConverter_sp>(llvmo::_sym_CodeGenFileType->symbolValue());
832+
this->_v = converter->enumForSymbol<llvm::CodeGenFileType>(so);
833+
return;
834+
}
835+
}
836+
SIMPLE_ERROR("You must pass a valid ");
837+
}
838+
};
839+
#endif
803840
}; // namespace translate
804841

805842
template <> struct gctools::GCInfo<llvmo::TargetMachine_O> {

src/core/commandLineOptions.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ void process_clasp_arguments(CommandLineOptions* options) {
405405
} else if (*arg == "-S" || *arg == "--seed") {
406406
options->_RandomNumberSeed = atoi((*++arg).c_str());
407407
} else {
408-
// Unknown option.
408+
fmt::print(std::cerr, "{}: unrecognized option '{}'\n", gctools::program_name(), *arg);
409+
exit(1);
409410
}
410411
}
411412

src/koga/configure.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@
489489
:documentation "mps setting")
490490
(ld :accessor ld ; TODO Add ld detection logic
491491
:initarg :ld
492-
:initform #+darwin nil #-darwin :gold
492+
:initform #+darwin :lld #-darwin :gold
493493
:type (member nil :bfd :lld :gold :mold)
494494
:documentation "The linker to use")
495495
(ar :accessor ar

src/koga/ninja.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
:description "Running pfdietz test-random-integer-forms"
168168
:pool "console")
169169
(ninja:write-rule output-stream :link-fasl
170-
:command "$clasp --norc --type image --disable-mpi --ignore-image --feature clasp-min --load link-fasl.lisp -- $out $in"
170+
:command "$clasp --norc --disable-mpi --ignore-image --feature clasp-min --load link-fasl.lisp -- $out $in"
171171
:restat 1
172172
:description "Linking $target")
173173
(ninja:write-rule output-stream "link-fasl-abc"

src/koga/units.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(in-package #:koga)
22

33
(defparameter +llvm-major-version+
4-
'(15 . 17)
4+
'(15 . 18)
55
"The required LLVM version.")
66

77
(defparameter +llvm-config-candidates+

src/lisp/kernel/cmp/cmpir.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ local-function - the lcl function that all of the xep functions call."
245245
fixed-indices))
246246

247247
(defun ensure-opaque-or-pointee-type-matches (ptr type)
248+
#+(or llvm15 llvm16 llvm17)
248249
(unless (llvm-sys:is-opaque-or-pointee-type-matches (llvm-sys:get-type ptr) type)
249250
(error "irc-typed-gep is-opaque-or-pointee-type-matches failed for type -> ~a value -> ~a (llvm-sys:get-type value) -> ~a"
250251
type ptr (llvm-sys:get-type ptr))))
@@ -431,8 +432,8 @@ local-function - the lcl function that all of the xep functions call."
431432
(defun irc-sext (val &optional (destty %fixnum%) (label "sext"))
432433
(llvm-sys:create-sext *irbuilder* val destty label))
433434

434-
(defun irc-zext (val &optional (destty %fixnum%) (label "sext"))
435-
(llvm-sys:create-zext *irbuilder* val destty label))
435+
(defun irc-zext (val &optional (destty %fixnum%) (label "zext") #+llvm18 is-non-neg)
436+
(llvm-sys:create-zext *irbuilder* val destty label #+llvm18 is-non-neg))
436437

437438
(defun irc-untag-fixnum (t* fixnum-type &optional (label "fixnum"))
438439
"Given a T* fixnum llvm::Value, returns a Value of the given type

src/llvmo/llvmoExpose.cc

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,12 +532,18 @@ CL_EXTERN_DEFMETHOD(Target_O, (llvm::TargetMachine * (llvm::Target::*)(llvm::Str
532532
const llvm::TargetOptions&, Optional<Reloc::Model>,
533533
Optional<CodeModel::Model>, CodeGenOpt::Level, bool) const) &
534534
llvm::Target::createTargetMachine);
535-
#else
535+
#elif LLVM_VERSION_MAJOR == 17
536536
CL_EXTERN_DEFMETHOD(Target_O,
537537
(llvm::TargetMachine * (llvm::Target::*)(llvm::StringRef, llvm::StringRef, llvm::StringRef,
538538
const llvm::TargetOptions&, std::optional<Reloc::Model>,
539539
std::optional<CodeModel::Model>, CodeGenOpt::Level, bool) const) &
540540
llvm::Target::createTargetMachine);
541+
#else
542+
CL_EXTERN_DEFMETHOD(Target_O,
543+
(llvm::TargetMachine * (llvm::Target::*)(llvm::StringRef, llvm::StringRef, llvm::StringRef,
544+
const llvm::TargetOptions&, std::optional<Reloc::Model>,
545+
std::optional<CodeModel::Model>, CodeGenOptLevel, bool) const) &
546+
llvm::Target::createTargetMachine);
541547
#endif
542548

543549
}; // namespace llvmo
@@ -647,24 +653,41 @@ SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenFileType_Null);
647653
SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenFileType_AssemblyFile);
648654
SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenFileType_ObjectFile);
649655
CL_BEGIN_ENUM(llvm::CodeGenFileType, _sym_CodeGenFileType, "CodeGenFileType");
656+
#if LLVM_VERSION_MAJOR < 18
650657
CL_VALUE_ENUM(_sym_CodeGenFileType_Null, llvm::CGFT_Null);
651658
CL_VALUE_ENUM(_sym_CodeGenFileType_AssemblyFile, llvm::CGFT_AssemblyFile);
652659
CL_VALUE_ENUM(_sym_CodeGenFileType_ObjectFile, llvm::CGFT_ObjectFile);
653660
;
661+
#else
662+
CL_VALUE_ENUM(_sym_CodeGenFileType_Null, llvm::CodeGenFileType::Null);
663+
CL_VALUE_ENUM(_sym_CodeGenFileType_AssemblyFile, llvm::CodeGenFileType::AssemblyFile);
664+
CL_VALUE_ENUM(_sym_CodeGenFileType_ObjectFile, llvm::CodeGenFileType::ObjectFile);
665+
;
666+
#endif
654667
CL_END_ENUM(_sym_CodeGenFileType);
655668

656669
SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenOpt);
657670
SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenOpt_None);
658671
SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenOpt_Less);
659672
SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenOpt_Default);
660673
SYMBOL_EXPORT_SC_(LlvmoPkg, CodeGenOpt_Aggressive);
674+
#if LLVM_VERSION_MAJOR < 18
661675
CL_BEGIN_ENUM(llvm::CodeGenOpt::Level, _sym_CodeGenOpt, "CodeGenOpt");
662676
CL_VALUE_ENUM(_sym_CodeGenOpt_None, llvm::CodeGenOpt::None);
663677
CL_VALUE_ENUM(_sym_CodeGenOpt_Less, llvm::CodeGenOpt::Less);
664678
CL_VALUE_ENUM(_sym_CodeGenOpt_Default, llvm::CodeGenOpt::Default);
665679
CL_VALUE_ENUM(_sym_CodeGenOpt_Aggressive, llvm::CodeGenOpt::Aggressive);
666680
;
667681
CL_END_ENUM(_sym_CodeGenOpt);
682+
#else
683+
CL_BEGIN_ENUM(llvm::CodeGenOptLevel, _sym_CodeGenOpt, "CodeGenOpt");
684+
CL_VALUE_ENUM(_sym_CodeGenOpt_None, llvm::CodeGenOptLevel::None);
685+
CL_VALUE_ENUM(_sym_CodeGenOpt_Less, llvm::CodeGenOptLevel::Less);
686+
CL_VALUE_ENUM(_sym_CodeGenOpt_Default, llvm::CodeGenOptLevel::Default);
687+
CL_VALUE_ENUM(_sym_CodeGenOpt_Aggressive, llvm::CodeGenOptLevel::Aggressive);
688+
;
689+
CL_END_ENUM(_sym_CodeGenOpt);
690+
#endif
668691

669692
SYMBOL_EXPORT_SC_(LlvmoPkg, RelocModel);
670693
SYMBOL_EXPORT_SC_(LlvmoPkg, RelocModel_undefined);
@@ -875,7 +898,6 @@ SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_OpenBSD);
875898
SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_Solaris);
876899
SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_Win32);
877900
SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_Haiku);
878-
SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_Minix);
879901
SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_RTEMS);
880902
SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_NaCl);
881903
// SYMBOL_EXPORT_SC_(LlvmoPkg, OSType_CNK);
@@ -900,7 +922,6 @@ CL_VALUE_ENUM(_sym_OSType_OpenBSD, llvm::Triple::OpenBSD);
900922
CL_VALUE_ENUM(_sym_OSType_Solaris, llvm::Triple::Solaris);
901923
CL_VALUE_ENUM(_sym_OSType_Win32, llvm::Triple::Win32);
902924
CL_VALUE_ENUM(_sym_OSType_Haiku, llvm::Triple::Haiku);
903-
CL_VALUE_ENUM(_sym_OSType_Minix, llvm::Triple::Minix);
904925
CL_VALUE_ENUM(_sym_OSType_RTEMS, llvm::Triple::RTEMS);
905926
CL_VALUE_ENUM(_sym_OSType_NaCl, llvm::Triple::NaCl);
906927
// CL_VALUE_ENUM(_sym_OSType_CNK, llvm::Triple::CNK);
@@ -1607,9 +1628,11 @@ CL_EXTERN_DEFMETHOD(ExecutionEngine_O, &llvm::ExecutionEngine::getOrEmitGlobalVa
16071628

16081629
namespace llvmo {
16091630

1631+
#if LLVM_VERSION_MAJOR < 18
16101632
CL_DEFUN bool llvm_sys__isOpaqueOrPointeeTypeMatches(Type_sp ptrType, Type_sp ty) {
16111633
return dyn_cast<llvm::PointerType>(ptrType->wrappedPtr())->isOpaqueOrPointeeTypeMatches(ty->wrappedPtr());
16121634
}
1635+
#endif
16131636

16141637
}; // namespace llvmo
16151638

@@ -1854,7 +1877,11 @@ CL_DEFUN core::T_mv llvm_sys__getDebugLocInfo(Instruction_sp instr) {
18541877
CL_DOCSTRING(R"dx(Erase the instruction from its parent basic block and return the next instruction or NIL)dx");
18551878
DOCGROUP(clasp);
18561879
CL_DEFUN void llvm_sys__instruction_eraseFromParent(Instruction_sp instr) {
1880+
#if LLVM_VERSION_MAJOR < 18
18571881
[[maybe_unused]] llvm::SymbolTableList<llvm::Instruction>::iterator next = instr->wrappedPtr()->eraseFromParent();
1882+
#else
1883+
[[maybe_unused]] llvm::AllocaInst::InstListType::iterator next = instr->wrappedPtr()->eraseFromParent();
1884+
#endif
18581885
}
18591886

18601887
CL_DOCSTRING(R"dx(Return the next non-debug instruction or NIL if there is none)dx");
@@ -1869,8 +1896,10 @@ CL_DEFUN core::T_sp llvm_sys__instruction_getNextNonDebugInstruction(Instruction
18691896

18701897
CL_LISPIFY_NAME("insertAfter");
18711898
CL_EXTERN_DEFMETHOD(Instruction_O, &llvm::Instruction::insertAfter);
1899+
#if LLVM_VERSION_MAJOR < 18
18721900
CL_LISPIFY_NAME("insertBefore");
18731901
CL_EXTERN_DEFMETHOD(Instruction_O, &llvm::Instruction::insertBefore);
1902+
#endif
18741903

18751904
CL_LISPIFY_NAME("terminatorInstP");
18761905
CL_DEFMETHOD bool Instruction_O::terminatorInstP() const { return this->wrappedPtr()->isTerminator(); }
@@ -3451,6 +3480,7 @@ CL_EXTERN_DEFUN((llvm::IntegerType * (*)(llvm::LLVMContext & C)) & llvm::Type::g
34513480
CL_LISPIFY_NAME("type-get-int128-ty");
34523481
CL_EXTERN_DEFUN((llvm::IntegerType * (*)(llvm::LLVMContext & C)) & llvm::Type::getInt128Ty);
34533482

3483+
#if LLVM_VERSION_MAJOR < 18
34543484
CL_LISPIFY_NAME("type-get-float-ptr-ty");
34553485
CL_EXTERN_DEFUN((llvm::PointerType * (*)(llvm::LLVMContext & C, unsigned AS)) & llvm::Type::getFloatPtrTy);
34563486
CL_LISPIFY_NAME("type-get-double-ptr-ty");
@@ -3469,6 +3499,7 @@ CL_EXTERN_DEFUN((llvm::PointerType * (*)(llvm::LLVMContext & C, unsigned AS)) &
34693499
CL_LISPIFY_NAME("type-get-int64-ptr-ty");
34703500
CL_EXTERN_DEFUN((llvm::PointerType * (*)(llvm::LLVMContext & C, unsigned AS)) & llvm::Type::getInt64PtrTy);
34713501
;
3502+
#endif
34723503

34733504
}; // namespace llvmo
34743505

src/llvmo/runtimeJit.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
#include <dlfcn.h>
1010
#include <iomanip>
1111
#include <string>
12+
#include <llvm/Config/llvm-config.h>
13+
#if LLVM_VERSION_MAJOR < 18
1214
#include <llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h>
15+
#else
16+
#include <llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h>
17+
#endif
1318
#include <llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h>
1419
#include <clasp/core/foundation.h>
1520
#include <clasp/core/object.h>

0 commit comments

Comments
 (0)