{"action":"created","issue":{"url":"https://api.github.com/repos/bazelbuild/rules_foreign_cc/issues/312","repository_url":"https://api.github.com/repos/bazelbuild/rules_foreign_cc","labels_url":"https://api.github.com/repos/bazelbuild/rules_foreign_cc/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/rules_foreign_cc/issues/312/comments","events_url":"https://api.github.com/repos/bazelbuild/rules_foreign_cc/issues/312/events","html_url":"https://github.com/bazelbuild/rules_foreign_cc/issues/312","id":489207939,"node_id":"MDU6SXNzdWU0ODkyMDc5Mzk=","number":312,"title":"BAZEL_GEN_ROOT in standalone builds isn't substituted on Linux, causing build failures","user":{"login":"mattgodbolt","id":633973,"node_id":"MDQ6VXNlcjYzMzk3Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/633973?v=4","gravatar_id":"","url":"https://api.github.com/users/mattgodbolt","html_url":"https://github.com/mattgodbolt","followers_url":"https://api.github.com/users/mattgodbolt/followers","following_url":"https://api.github.com/users/mattgodbolt/following{/other_user}","gists_url":"https://api.github.com/users/mattgodbolt/gists{/gist_id}","starred_url":"https://api.github.com/users/mattgodbolt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattgodbolt/subscriptions","organizations_url":"https://api.github.com/users/mattgodbolt/orgs","repos_url":"https://api.github.com/users/mattgodbolt/repos","events_url":"https://api.github.com/users/mattgodbolt/events{/privacy}","received_events_url":"https://api.github.com/users/mattgodbolt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-09-04T14:47:00Z","updated_at":"2019-10-02T09:51:39Z","closed_at":"2019-10-02T09:51:38Z","author_association":"NONE","body":"Due to issues seen in #306 building dependent libraries does not work: the `BAZEL_GEN_ROOT` is not substituted leading to build errors down the line, when using `--spawn_strategy=standalone`. The same build works with sandboxing (but use of sandboxing with remote caching is discouraged).\r\n\r\nAn example:\r\n\r\n--- WORKSPACE\r\n```\r\nload(\"@bazel_tools//tools/build_defs/repo:git.bzl\", \"git_repository\")\r\nload(\"@bazel_tools//tools/build_defs/repo:http.bzl\", \"http_archive\")\r\n\r\nall_content = \"\"\"filegroup(name = \"all\", srcs = glob([\"**\"]), visibility = [\"//visibility:public\"])\"\"\"\r\n\r\ngit_repository(\r\n    name = \"rules_foreign_cc\",\r\n    commit = \"c3d5405cbc570257e7c9f75f902fab42241e6a53\",\r\n    remote = \"https://github.com/bazelbuild/rules_foreign_cc.git\",\r\n    shallow_since = \"1565168152 +0200\",\r\n)\r\n\r\nload(\"@rules_foreign_cc//:workspace_definitions.bzl\", \"rules_foreign_cc_dependencies\")\r\n\r\nrules_foreign_cc_dependencies()\r\n\r\nhttp_archive(\r\n    name = \"openssl\",\r\n    build_file_content = all_content,\r\n    sha256 = \"f56dd7d81ce8d3e395f83285bd700a1098ed5a4cb0a81ce9522e41e6db7e0389\",\r\n    strip_prefix = \"openssl-OpenSSL_1_1_0h\",\r\n    url = \"https://github.com/openssl/openssl/archive/OpenSSL_1_1_0h.tar.gz\",\r\n)\r\nhttp_archive(\r\n    name = \"curl\",\r\n    build_file_content = all_content,\r\n    sha256 = \"4376ac72b95572fb6c4fbffefb97c7ea0dd083e1974c0e44cd7e49396f454839\",\r\n    strip_prefix = \"curl-7.65.3\",\r\n    urls = [\"https://curl.haxx.se/download/curl-7.65.3.tar.gz\"],\r\n)\r\n```\r\n\r\n--- BUILD\r\n```\r\nload(\"@rules_foreign_cc//tools/build_defs:configure.bzl\", \"configure_make\")\r\n\r\nconfigure_make(\r\n    name = \"openssl\",\r\n    configure_command = \"config\",\r\n    lib_source = \"@openssl//:all\",\r\n    static_libraries = [\r\n        \"libssl.a\",\r\n        \"libcrypto.a\",\r\n    ],\r\n    visibility = [\"//visibility:public\"],\r\n)\r\n\r\nconfigure_make(\r\n    name = \"curl\",\r\n    lib_source = \"@curl//:all\",\r\n    static_libraries = [\"libcurl.a\"],\r\n    visibility = [\"//visibility:public\"],\r\n    deps = [\r\n        \":openssl\",\r\n    ],\r\n)\r\n```\r\n\r\nRun: `$ bazel build //...`\r\n\r\nOutput:\r\n\r\n```\r\n~/bazel-rulescc-bug $ bazel build --spawn_strategy=standalone //...\r\nINFO: Analyzed 2 targets (16 packages loaded, 9964 targets configured).\r\nINFO: Found 2 targets...\r\nINFO: From CcConfigureMakeRule openssl/include:\r\n\r\nERROR: /home/mgodbolt/bazel-rulescc-bug/BUILD:14:1: error executing shell command: '/bin/bash -c function cleanup_function() {\r\nlocal ecode=$?\r\nif [ $ecode -eq 0 ]; then\r\ncleanup_on_success\r\n...\r\n_=/usr/bin/env\r\n__________________________sed: couldn't open temporary file /home/mgodbolt/.cache/bazel/_bazel_mgodbolt/6a5050bedf5d8d30783a2db385994fa4/execroot/__main__/bazel_foreign_cc_deps_curl/openssl/lib/pkgconfig/sedCtBrk2: Permission denied\r\nsed: couldn't open temporary file /home/mgodbolt/.cache/bazel/_bazel_mgodbolt/6a5050bedf5d8d30783a2db385994fa4/execroot/__main__/bazel_foreign_cc_deps_curl/openssl/lib/pkgconfig/sed3p6B20: Permission denied\r\nsed: couldn't open temporary file /home/mgodbolt/.cache/bazel/_bazel_mgodbolt/6a5050bedf5d8d30783a2db385994fa4/execroot/__main__/bazel_foreign_cc_deps_curl/openssl/lib/pkgconfig/sedDNqnO0: Permission denied\r\nPKG_CONFIG_PATH=:/home/mgodbolt/.cache/bazel/_bazel_mgodbolt/6a5050bedf5d8d30783a2db385994fa4/execroot/__main__/bazel-out/k8-fastbuild/bin/copy_openssl/openssl/lib/pkgconfig\r\nchecking whether to enable maintainer-specific portions of Makefiles... no\r\n...\r\n  CC       vtls/libcurl_la-schannel_verify.lo\r\n  CC       vtls/libcurl_la-sectransp.lo\r\n  CC       vtls/libcurl_la-gskit.lo\r\n  CC       vtls/libcurl_la-mbedtls.lo\r\n  CC       vtls/libcurl_la-mesalink.lo\r\n  CCLD     libcurl.la\r\n../libtool: line 7566: cd: BAZEL_GEN_ROOT/openssl/lib: No such file or directory\r\nlibtool:   error: cannot determine absolute directory name of 'BAZEL_GEN_ROOT/openssl/lib'\r\nmake[2]: *** [Makefile:1184: libcurl.la] Error 1\r\nmake[2]: Leaving directory '/tmp/tmp.n3iYKLwYV2/lib'\r\nmake[1]: *** [Makefile:1023: all] Error 2\r\nmake[1]: Leaving directory '/tmp/tmp.n3iYKLwYV2/lib'\r\nmake: *** [Makefile:922: all-recursive] Error 1\r\n\r\n_____ END BUILD LOGS _____\r\nrules_foreign_cc: Build script location: bazel-out/k8-fastbuild/bin/curl/logs/Configure_script.sh\r\nrules_foreign_cc: Build log location: bazel-out/k8-fastbuild/bin/curl/logs/Configure.log\r\n\r\nINFO: Elapsed time: 227.351s, Critical Path: 226.17s\r\nINFO: 1 process: 1 local.\r\nFAILED: Build did NOT complete successfully\r\n```\r\n\r\nNote the `sed` errors early on, which are the cause of the issue (see #306). Errors in `replace_in_path` are dropped, it seems."},"comment":{"url":"https://api.github.com/repos/bazelbuild/rules_foreign_cc/issues/comments/537421634","html_url":"https://github.com/bazelbuild/rules_foreign_cc/issues/312#issuecomment-537421634","issue_url":"https://api.github.com/repos/bazelbuild/rules_foreign_cc/issues/312","id":537421634,"node_id":"MDEyOklzc3VlQ29tbWVudDUzNzQyMTYzNA==","user":{"login":"irengrig","id":6598461,"node_id":"MDQ6VXNlcjY1OTg0NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/6598461?v=4","gravatar_id":"","url":"https://api.github.com/users/irengrig","html_url":"https://github.com/irengrig","followers_url":"https://api.github.com/users/irengrig/followers","following_url":"https://api.github.com/users/irengrig/following{/other_user}","gists_url":"https://api.github.com/users/irengrig/gists{/gist_id}","starred_url":"https://api.github.com/users/irengrig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irengrig/subscriptions","organizations_url":"https://api.github.com/users/irengrig/orgs","repos_url":"https://api.github.com/users/irengrig/repos","events_url":"https://api.github.com/users/irengrig/events{/privacy}","received_events_url":"https://api.github.com/users/irengrig/received_events","type":"User","site_admin":false},"created_at":"2019-10-02T09:51:38Z","updated_at":"2019-10-02T09:51:38Z","author_association":"COLLABORATOR","body":"Fixed by #324 "}}
{"actor":{"display_login":"irengrig"}}