diff --git a/Package.swift b/Package.swift index fb95ef7eb..305bce44a 100644 --- a/Package.swift +++ b/Package.swift @@ -2,30 +2,13 @@ import PackageDescription -#if arch(arm) || arch(arm64) -let platforms: [SupportedPlatform]? = [ - .macOS(.v11), - .iOS(.v14), - .watchOS(.v4), - .tvOS(.v14) -] -let exclude: [String] = [] -let additionalSources: [String] = ["ggml-metal.m"] -let additionalSettings: [CSetting] = [ - .unsafeFlags(["-fno-objc-arc"]), - .define("GGML_SWIFT"), - .define("GGML_USE_METAL") -] -#else -let platforms: [SupportedPlatform]? = nil -let exclude: [String] = ["ggml-metal.metal"] -let additionalSources: [String] = [] -let additionalSettings: [CSetting] = [] -#endif - let package = Package( name: "llama", - platforms: platforms, + platforms: [.macOS(.v11), + .iOS(.v14), + .watchOS(.v4), + .tvOS(.v14) + ], products: [ .library(name: "llama", targets: ["llama"]), ], @@ -33,21 +16,79 @@ let package = Package( .target( name: "llama", path: ".", - exclude: exclude, sources: [ "ggml.c", "llama.cpp", "ggml-alloc.c", "k_quants.c", - ] + additionalSources, + "ggml-metal.m" + ], publicHeadersPath: "spm-headers", cSettings: [ - .unsafeFlags(["-Wno-shorten-64-to-32"]), + .unsafeFlags(["-Wno-shorten-64-to-32", + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wcast-qual", + "-Wstrict-prototypes", + "-Wpointer-arith", + "-Wdouble-promotion", + "-Wno-unused-function", + "-Wmissing-prototypes", + "-Werror=vla", + "-mavx", + "-mavx2", + "-mfma", + "-mf16c", + "-O3", + "-DNDEBUG", + "-Wno-format", + "-mf16c"]), .define("GGML_USE_K_QUANTS"), - .define("GGML_USE_ACCELERATE") - ] + additionalSettings, + .define("GGML_USE_ACCELERATE"), + .define("NDEBUG"), + .define("_XOPEN_SOURCE", to: "600"), + .define("_DARWIN_C_SOURCE"), + .unsafeFlags(["-fno-objc-arc"]), + .define("GGML_SWIFT"), + .define("GGML_USE_METAL") + ], + cxxSettings: [ + .unsafeFlags(["-Wno-shorten-64-to-32", + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wcast-qual", + "-Wstrict-prototypes", + "-Wpointer-arith", + "-Wdouble-promotion", + "-Wno-unused-function", + "-Wmissing-prototypes", + "-Werror=vla", + "-mavx", + "-mavx2", + "-mfma", + "-mf16c", + "-O3", + "-DNDEBUG", + "-Wno-format", + "-mf16c"]), + .define("GGML_USE_K_QUANTS"), + .define("GGML_USE_ACCELERATE"), + .unsafeFlags(["-fno-objc-arc"]), + .define("GGML_SWIFT"), + .define("GGML_USE_METAL"), + .define("NDEBUG"), + .define("_XOPEN_SOURCE", to: "600"), + .define("_DARWIN_C_SOURCE") + ], linkerSettings: [ - .linkedFramework("Accelerate") + .linkedFramework("Accelerate"), + .linkedFramework("Foundation"), + .linkedFramework("Metal"), + .linkedFramework("MetalKit") ] ) ],