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

nocopts seems not woking in some cases #5033

Closed
shiltian opened this issue Apr 17, 2018 · 5 comments
Closed

nocopts seems not woking in some cases #5033

shiltian opened this issue Apr 17, 2018 · 5 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: bug

Comments

@shiltian
Copy link

Description of the problem / feature request:

The nocopts has been set correctly, but there are still flags which are in the nocopts appearing in the running command. For example, given the following rule, the opts -fno-exceptions still exists in the final running command, although I've set the arg nocopts explicitly.

def tf_cc_test(name,
               srcs,
               deps,
               linkstatic=0,
               extra_copts=[],
               suffix="",
               linkopts=[],
               nocopts=None,
               **kwargs):
  native.cc_test(
      name="%s%s" % (name, suffix),
      srcs=...,
      copts=["-fno-exceptions"] + ...,
      ............
      nocopts="-fno-exceptions")

What operating system are you running Bazel on?

macOS High Sierra 10.13.4

What's the output of bazel info release?

release 0.12.0-homebrew

Have you found anything relevant by searching the web?

Nope.

@c-parsons c-parsons added P3 We're not considering working on this, but happy to review a PR. (No assignee) category: rules > C++ labels Apr 17, 2018
@lberki lberki assigned hlopko and unassigned lberki Apr 18, 2018
@hlopko
Copy link
Member

hlopko commented Apr 25, 2018

Hmm cannot reproduce, is it an option to create a small repro case? What I tried:

cc_binary(
    name = "foo",
    copts = [ "-fno-exceptions" ],
    nocopts = "-fno-exceptions",
    srcs = [ "foo.cc" ]
)

and I don't see -fno-exceptions on the command line.

@shiltian
Copy link
Author

Hi @mhlopko
Thanks for your response. I'm sorry but I'm very busy during these days, so I'll show you the details once I'm free.

@shiltian
Copy link
Author

Hi @mhlopko , I'm really sorry for the laaaaaaaate reply.

Actually, I have such a macro:

def tf_cc_test_mkl(srcs, deps, name="", linkstatic=0, tags=[], size="medium", args=None):
  for src in srcs:
    native.cc_test(
      name=src_to_test_name(src),
      srcs=if_mkl([src]) + tf_binary_additional_srcs(),
      copts=tf_copts(),
      linkopts=select({
        clean_dep("//tensorflow:android"): [
            "-pie",
          ],
        clean_dep("//tensorflow:windows"): [],
        clean_dep("//tensorflow:windows_msvc"): [],
        "//conditions:default": [
            "-lpthread",
            "-lm"
        ],
      }) + _rpath_linkopts(src_to_test_name(src)),
      deps=deps + if_mkl(
          [
              "//third_party/mkl:intel_binary_blob",
          ],
      ),
      linkstatic=linkstatic,
      tags=tags,
      size=size,
      args=args,
      nocopts="-fno-exceptions")

which copied from the tensoflow.bzl in the project TensorFlow. You can see the last argument is nocopts in the rule native.cc_test , and the default value is -fno-exceptions which I want to strip this option from the copts. However, unfortunately, it looks like not working because I can still see this flag in the final command, landing to a building error. This flag is included in the macro tf_copts which passed in the 3rd argument.

ERROR: /home/shilei/Documents/dl_framework-tensorflow_sh/tensorflow/core/kernels/BUILD:273:1: C++ compilation of rule '//tensorflow/core/kernels:mkl_ops_testutil' failed (Exit 1): gcc failed: error executing command 
  (cd /home/shilei/.cache/bazel/_bazel_shilei/9006bf5c0b27f0545f123e5dfa278bea/execroot/org_tensorflow && \
  exec env - \
    PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin \
    PWD=/proc/self/cwd \
    PYTHON_BIN_PATH=/usr/bin/python \
    PYTHON_LIB_PATH=/usr/lib/python2.7/site-packages \
    TF_DOWNLOAD_CLANG=0 \
    TF_NEED_CUDA=0 \
    TF_NEED_OPENCL_SYCL=0 \
  /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections -DINTEL_MKL_DNN '-std=c++0x' -I/home/shilei/.local/include -MD -MF bazel-out/k8-opt/bin/tensorflow/core/kernels/_objs/mkl_ops_testutil/tensorflow/core/kernels/mkl_ops_testutil.d '-frandom-seed=bazel-out/k8-opt/bin/tensorflow/core/kernels/_objs/mkl_ops_testutil/tensorflow/core/kernels/mkl_ops_testutil.o' -DEIGEN_MPL2_ONLY '-DEIGEN_MAX_ALIGN_BYTES=64' -D__CLANG_SUPPORT_DYN_ANNOTATION__ -DTENSORFLOW_USE_ABSL -DTF_USE_SNAPPY -iquote . -iquote bazel-out/k8-opt/genfiles -iquote external/bazel_tools -iquote bazel-out/k8-opt/genfiles/external/bazel_tools -iquote external/eigen_archive -iquote bazel-out/k8-opt/genfiles/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/k8-opt/genfiles/external/local_config_sycl -iquote external/com_google_absl -iquote bazel-out/k8-opt/genfiles/external/com_google_absl -iquote external/nsync -iquote bazel-out/k8-opt/genfiles/external/nsync -iquote external/gif_archive -iquote bazel-out/k8-opt/genfiles/external/gif_archive -iquote external/jpeg -iquote bazel-out/k8-opt/genfiles/external/jpeg -iquote external/protobuf_archive -iquote bazel-out/k8-opt/genfiles/external/protobuf_archive -iquote external/com_googlesource_code_re2 -iquote bazel-out/k8-opt/genfiles/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/k8-opt/genfiles/external/farmhash_archive -iquote external/fft2d -iquote bazel-out/k8-opt/genfiles/external/fft2d -iquote external/highwayhash -iquote bazel-out/k8-opt/genfiles/external/highwayhash -iquote external/png_archive -iquote bazel-out/k8-opt/genfiles/external/png_archive -iquote external/zlib_archive -iquote bazel-out/k8-opt/genfiles/external/zlib_archive -iquote external/double_conversion -iquote bazel-out/k8-opt/genfiles/external/double_conversion -iquote external/mkl_linux -iquote bazel-out/k8-opt/genfiles/external/mkl_linux -iquote external/mkl_dnn -iquote bazel-out/k8-opt/genfiles/external/mkl_dnn -iquote external/com_google_googletest -iquote bazel-out/k8-opt/genfiles/external/com_google_googletest -isystem external/bazel_tools/tools/cpp/gcc3 -isystem third_party/eigen3/mkl_include -isystem bazel-out/k8-opt/genfiles/third_party/eigen3/mkl_include -isystem external/eigen_archive -isystem bazel-out/k8-opt/genfiles/external/eigen_archive -isystem external/nsync/public -isystem bazel-out/k8-opt/genfiles/external/nsync/public -isystem external/gif_archive/lib -isystem bazel-out/k8-opt/genfiles/external/gif_archive/lib -isystem external/protobuf_archive/src -isystem bazel-out/k8-opt/genfiles/external/protobuf_archive/src -isystem external/farmhash_archive/src -isystem bazel-out/k8-opt/genfiles/external/farmhash_archive/src -isystem external/png_archive -isystem bazel-out/k8-opt/genfiles/external/png_archive -isystem external/zlib_archive -isystem bazel-out/k8-opt/genfiles/external/zlib_archive -isystem external/double_conversion -isystem bazel-out/k8-opt/genfiles/external/double_conversion -isystem external/mkl_linux/include -isystem bazel-out/k8-opt/genfiles/external/mkl_linux/include -isystem external/mkl_dnn/include -isystem bazel-out/k8-opt/genfiles/external/mkl_dnn/include -isystem external/mkl_dnn/src -isystem bazel-out/k8-opt/genfiles/external/mkl_dnn/src -isystem external/mkl_dnn/src/common -isystem bazel-out/k8-opt/genfiles/external/mkl_dnn/src/common -isystem external/mkl_dnn/src/cpu -isystem bazel-out/k8-opt/genfiles/external/mkl_dnn/src/cpu -isystem external/mkl_dnn/src/cpu/xbyak -isystem bazel-out/k8-opt/genfiles/external/mkl_dnn/src/cpu/xbyak -isystem external/com_google_googletest/googlemock -isystem bazel-out/k8-opt/genfiles/external/com_google_googletest/googlemock -isystem external/com_google_googletest/googlemock/include -isystem bazel-out/k8-opt/genfiles/external/com_google_googletest/googlemock/include -isystem external/com_google_googletest/googletest -isystem bazel-out/k8-opt/genfiles/external/com_google_googletest/googletest -isystem external/com_google_googletest/googletest/include -isystem bazel-out/k8-opt/genfiles/external/com_google_googletest/googletest/include -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare -fno-exceptions '-ftemplate-depth=900' '-DINTEL_MKL=1' -DEIGEN_USE_VML -fopenmp -msse3 -pthread '-DINTEL_MKL=1' -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c tensorflow/core/kernels/mkl_ops_testutil.cc -o bazel-out/k8-opt/bin/tensorflow/core/kernels/_objs/mkl_ops_testutil/tensorflow/core/kernels/mkl_ops_testutil.o)
In file included from ./tensorflow/core/util/mkl_util.h:41:0,
                 from ./tensorflow/core/kernels/mkl_ops_testutil.h:21,
                 from tensorflow/core/kernels/mkl_ops_testutil.cc:17:
external/mkl_dnn/include/mkldnn.hpp: In static member function 'static void mkldnn::error::wrap_c_api(mkldnn_status_t, std::string, mkldnn_primitive**)':
external/mkl_dnn/include/mkldnn.hpp:190:62: error: exception handling disabled, use -fexceptions to enable
                 throw error(status, message, *error_primitive);

@shiltian
Copy link
Author

I'm wondering whether this issue only exists in the rule of cc_test as nocopts is also in another rules of cc_library in the TensorFlow and they can work well.

@hlopko hlopko added team-Rules-CPP Issues for C++ rules and removed category: rules > C++ labels Oct 11, 2018
@hlopko hlopko removed their assignment Dec 6, 2019
@dmadisetti
Copy link

nocopts was removed #8706

@shiltian shiltian closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

6 participants