Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: bazel脚本编写问题 #396

Closed
yongzhao-yan-postgraduate opened this issue Nov 9, 2023 · 9 comments
Closed

[Feature]: bazel脚本编写问题 #396

yongzhao-yan-postgraduate opened this issue Nov 9, 2023 · 9 comments

Comments

@yongzhao-yan-postgraduate

Feature Request Type

Usability

Have you searched existing issues?

Yes

Is your feature request related to a problem?

spu_cc_library(
name = "global_variable",
hdrs = ["global_variable.h"],

)
这么写bazel脚本可以吗,
为什么存在以下问题
ERROR: /home/test/Desktop/xxx/spu-main/spu-main/libspu/pir/BUILD.bazel:110:15: Compiling libspu/pir/ht_pir.cc failed: (Exit 1): gcc failed: error executing command (from target //libspu/pir:ht_pir) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 172 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from libspu/pir/ht_pir.cc:1:
./libspu/pir/ht_pir.h:8:10: fatal error: libspu/pir/global_variable.h: No such file or directory
8 | #include "libspu/pir/global_variable.h"//定义了程序使用的全局变量
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
ERROR: /home/test/Desktop/xxx/spu-main/spu-main/examples/cpp/pir/BUILD.bazel:150:14: Compiling examples/cpp/pir/ht_keyword_pir_setup.cc failed: (Exit 1): gcc failed: error executing command (from target //examples/cpp/pir:ht_keyword_pir_setup) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 175 arguments skipped)

Describe features you want to add to SPU

no

Describe features you want to add to SPU

no

@anakinxc
Copy link
Collaborator

anakinxc commented Nov 9, 2023

Hi @yongzhao-yan-postgraduate

这个 bazel rule 本身没什么问题,但是 ht_pir 的 deps 里得加入 global_variable,详细可以参考一下 bazel 文档

@yongzhao-yan-postgraduate
Copy link
Author

为什么只包含头文件的spu_cc_library会出现错误

@anakinxc
Copy link
Collaborator

Hi @yongzhao-yan-postgraduate

从 log 上来看,只是 ht_pir 缺少了依赖,并不是只包含头文件的 cc_library 造成的

@yongzhao-yan-postgraduate
Copy link
Author

这两个文件在一个文件夹也要写进依赖库吗

@anakinxc
Copy link
Collaborator

除非 global_variable.h 和 ht_pir.cc 是在同一个 cc_library 下面,否则必须要 explicit 的写在 deps 里面。
bazel 都是用 sandbox 来 build 的,不在 deps 里的都在编译时不可见

@yongzhao-yan-postgraduate
Copy link
Author

ERROR: /home/test/Desktop/xxx/spu-main/spu-main/libspu/pir/BUILD.bazel:110:15: no such package 'libspu/pir/global_variable': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.

  • /home/test/Desktop/xxx/spu-main/spu-main/libspu/pir/global_variable and referenced by '//libspu/pir:ht_pir'
    ERROR: Analysis of target '//examples/cpp/pir:ht_keyword_pir_setup' failed; build aborted:
    INFO: Elapsed time: 1.108s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (4 packages loaded, 22 targets con
    figured)
    currently loading: @com_google_absl//absl
    Fetching repository @llvm-project; starting
    写入仍然存在错误

@anakinxc
Copy link
Collaborator

麻烦贴一下你怎么写的

@yongzhao-yan-postgraduate
Copy link
Author

Copyright 2022 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.

load("//bazel:spu.bzl", "spu_cc_library", "spu_cc_test")

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

spu_cc_library(
name = "seal_pir",
srcs = ["seal_pir.cc"],
hdrs = ["seal_pir.h"],
linkopts = [
"-ldl",
"-lm",
],
deps = [
":seal_pir_utils",
":serializable_cc_proto",
"//libspu/core:prelude",
"@com_github_microsoft_seal//:seal",
"@com_github_openssl_openssl//:openssl",
"@yacl//yacl/base:byte_container_view",
"@yacl//yacl/link",
"@yacl//yacl/utils:parallel",
],
)

spu_cc_library(
name = "seal_pir_utils",
srcs = ["seal_pir_utils.cc"],
hdrs = ["seal_pir_utils.h"],
deps = [
"//libspu/core:prelude",
"@com_github_microsoft_seal//:seal",
],
)

spu_cc_library(
name = "seal_mpir",
srcs = ["seal_mpir.cc"],
hdrs = ["seal_mpir.h"],
deps = [
":seal_pir",
"//libspu/psi/core:cuckoo_index",
"@yacl//yacl/crypto/base:symmetric_crypto",
],
)

proto_library(
name = "serializable_proto",
srcs = ["serializable.proto"],
)

cc_proto_library(
name = "serializable_cc_proto",
deps = [":serializable_proto"],
)

spu_cc_test(
name = "seal_pir_test",
srcs = ["seal_pir_test.cc"],
deps = [
":seal_pir",
],
)

spu_cc_test(
name = "seal_mpir_test",
srcs = ["seal_mpir_test.cc"],
deps = [
":seal_mpir",
"//libspu/psi/cryptor:sodium_curve25519_cryptor",
"@com_google_absl//absl/strings",
],
)

proto_library(
name = "pir_proto",
srcs = ["pir.proto"],
)

cc_proto_library(
name = "pir_cc_proto",
deps = [":pir_proto"],
)

spu_cc_library(
name = "pir",
srcs = ["pir.cc"],
hdrs = ["pir.h"],
deps = [
":pir_cc_proto",
"//libspu/psi/core:cuckoo_index",
"//libspu/psi/core/labeled_psi",
"@yacl//yacl/crypto/base:symmetric_crypto",
],
)

spu_cc_library(
name = "ht_pir",
srcs = ["ht_pir.cc"],
hdrs = ["ht_pir.h"],
deps = [
":pir_cc_proto",
"//examples/cpp:utils",
"//libspu/psi/core/labeled_psi",
"//libspu/psi/utils",
"//libspu/pir/global_variable",
"@yacl//yacl/link",
],
)
spu_cc_library(
name = "big_num",
srcs = ["big_num.c"],
hdrs = ["big_num.h"],

)

spu_cc_library(
name = "point",
srcs = ["point.c"],
hdrs = ["point.h"],

)

spu_cc_library(
name = "sm3_kdf",
srcs = ["sm3_kdf.c"],
hdrs = ["sm3_kdf.h"],

)

spu_cc_library(
name = "SM4",
srcs = ["SM4.c"],
hdrs = ["SM4.h"],

)

spu_cc_library(
name = "tools",
srcs = ["tools.c"],
hdrs = ["tools.h"],

)

spu_cc_library(
name = "global_variable",
hdrs = ["global_variable.h"],

)

@anakinxc
Copy link
Collaborator

"//libspu/pir/global_variable",

替换成

":global_variable"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants