1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'Machine Learning')
AllowCompilerWarnings()
include('sources.mozbuild')
SOURCES += files["COMMON_SOURCES"]
if CONFIG['TARGET_CPU'] == 'x86_64':
SOURCES += files['X64_SOURCES']
# unconditionaly enabled avx2 on x86_64 -- the library is only loaded if
# AVX2 is supported
CXXFLAGS += [
"-mavx",
"-mavx2",
"-mbmi2",
"-mf16c",
"-mfma",
"-msse4.2",
]
CFLAGS += [
"-mavx",
"-mavx2",
"-mbmi2",
"-mf16c",
"-mfma",
"-msse4.2",
]
# DEFINES["GGML_SSE42"] = 1
# DEFINES["GGML_F16C"] = 1
# DEFINES["GGML_FMA"] = 1
# DEFINES["GGML_BMI2"] = 1
# DEFINES["GGML_AVX"] = 1
# DEFINES["GGML_AVX2"] = 1
elif CONFIG['TARGET_CPU'] == 'x86':
SOURCES += files['IA32_SOURCES']
elif CONFIG['TARGET_CPU'] == 'aarch64':
SOURCES += files['ARM64_SOURCES']
elif CONFIG['TARGET_CPU'] == 'arm':
SOURCES += files['ARM_SOURCES']
else:
DEFINES["GGML_CPU_GENERIC"] = 1
EXPORTS.llama += [
"include/llama.h",
]
LOCAL_INCLUDES += [
'ggml/',
'ggml/include/',
'ggml/src/',
'ggml/src/ggml-cpu/',
'include/',
]
EXPORTS += [
"ggml/include/ggml-alloc.h",
"ggml/include/ggml-backend.h",
"ggml/include/ggml-cpu.h",
"ggml/include/ggml-opt.h",
"ggml/include/ggml.h",
]
DEFINES["_GNU_SOURCE"] = 1
DEFINES["GGML_USE_CPU"] = 1
DEFINES["GGML_VERSION"] = "\"GGML_VERSION\""
DEFINES["GGML_COMMIT"] = "\"GGML_COMMIT\""
# Control symbol visibility
DEFINES['GGML_SHARED'] = '1'
DEFINES['LLAMA_SHARED'] = '1'
DEFINES['GGML_BUILD'] = '1'
DEFINES['LLAMA_BUILD'] = '1'
DEFINES['GGML_BACKEND_SHARED'] = '1'
DEFINES['GGML_BACKEND_BUILD'] = '1'
CFLAGS += [
'-Wno-sign-compare',
'-Wno-unused-function',
'-Wno-unreachable-code',
'-Wno-tautological-unsigned-enum-zero-compare',
]
CXXFLAGS += [
'-Wno-sign-compare',
'-Wno-unused-function',
'-Wno-tautological-unsigned-enum-zero-compare',
'-Wno-implicit-fallthrough',
'-Wno-unreachable-code',
]
# Only disable those warnings on old clangs.
if CONFIG["CC_TYPE"] == "clang" and int(CONFIG["CC_VERSION"].split(".")[0]) <= 8:
CXXFLAGS += [
'-Wno-unused-variable',
'-Wno-unused-value'
]
CFLAGS += [
'-Wno-unused-variable',
]
if CONFIG["CC_TYPE"] != "gcc":
# g++ doesn't supports this warning, only gcc does
CFLAGS += [
'-Wno-absolute-value'
]
if CONFIG['OS_TARGET'] == "WINNT":
DEFINES["UNICODE"] = 1
CFLAGS += [
'-Wno-macro-redefined',
]
CXXFLAGS += [
'-Wno-macro-redefined',
]
if CONFIG['OS_TARGET'] == 'Darwin':
DEFINES["GGML_USE_ACCELERATE"] = 1
OS_LIBS += [
"-framework Accelerate"
]
if CONFIG["OS_TARGET"] == "Linux":
OS_LIBS += [
"dl",
]
if CONFIG["OS_TARGET"] == "WINNT":
OS_LIBS += [
"advapi32",
]
FINAL_LIBRARY = 'mozinference'
|