Skip to content

Commit

Permalink
Fix build failures on ARM platform (#227)
Browse files Browse the repository at this point in the history
* fix build failures on ARM platform

* turn off -Werror=mismatched-new-delete cxxopt on linux_aarch64
  • Loading branch information
tongke6 authored Dec 18, 2024
1 parent 07bca62 commit ed9a8d6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ build:macos --features=-supports_dynamic_linker
build:macos --macos_minimum_os=12.0
build:macos --host_macos_minimum_os=12.0

# NOTE: fix build on linux_aarch64, since `build:linux_aarch64` works only if `--config linux_aarch64` option included.
build:linux --cxxopt=-Wno-mismatched-new-delete

build:asan --features=asan
build:ubsan --features=ubsan
7 changes: 4 additions & 3 deletions psi/algorithm/spiral/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

load("//bazel:psi.bzl", "psi_cc_library", "psi_cc_test")
load(":copts.bzl", "spiral_copts")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -64,7 +65,7 @@ psi_cc_library(
name = "poly_matrix",
srcs = ["poly_matrix.cc"],
hdrs = ["poly_matrix.h"],
copts = ["-mavx2"],
copts = spiral_copts(),
deps = [
":params",
":util",
Expand All @@ -90,7 +91,7 @@ psi_cc_library(
name = "poly_matrix_utils",
srcs = ["poly_matrix_utils.cc"],
hdrs = ["poly_matrix_utils.h"],
copts = ["-mavx2"],
copts = spiral_copts(),
deps = [
"poly_matrix",
":params",
Expand All @@ -111,7 +112,7 @@ psi_cc_library(
psi_cc_test(
name = "poly_matrix_test",
srcs = ["poly_matrix_test.cc"],
copts = ["-mavx2"],
copts = spiral_copts(),
deps = [
"poly_matrix",
"poly_matrix_utils",
Expand Down
5 changes: 3 additions & 2 deletions psi/algorithm/spiral/arith/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//bazel:psi.bzl", "psi_cc_library", "psi_cc_test")
load("//psi/algorithm/spiral:copts.bzl", "spiral_copts")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -58,7 +59,7 @@ psi_cc_library(
name = "ntt",
srcs = ["ntt.cc"],
hdrs = ["ntt.h"],
copts = ["-mavx2"],
copts = spiral_copts(),
deps = [
":arith",
":ntt_table",
Expand Down Expand Up @@ -100,7 +101,7 @@ psi_cc_test(
psi_cc_test(
name = "ntt_table_test",
srcs = ["ntt_table_test.cc"],
copts = ["-mavx2"],
copts = spiral_copts(),
deps = [
":ntt",
":ntt_table",
Expand Down
21 changes: 21 additions & 0 deletions psi/algorithm/spiral/copts.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

def spiral_copts():
return select({
"@platforms//cpu:aarch64": [],
"//conditions:default": [
"-mavx",
],
})

0 comments on commit ed9a8d6

Please sign in to comment.