Skip to content

remove .bazelrc from git tree - #22906

Closed
samikama wants to merge 3 commits into
tensorflow:masterfrom
samikama:dont_add_.bazelrc_into_git
Closed

samikama wants to merge 3 commits into
tensorflow:masterfrom
samikama:dont_add_.bazelrc_into_git

Conversation

@samikama

@samikama samikama commented Oct 11, 2018 •

Copy link
Copy Markdown
Contributor

This PR removes .bazelrc from the git tree. Since it is modified during the configure, in essence it is a generated file and should not have been placed into the tree in the first place. Instead this PR adds a new file bazel_defaults and uses it to generate .bazelrc file. Also certain flags are such as -c opt and some environment variables that are not necessarily valid under all circumstances are disabled with this PR. Since these are mostly platform specific or override user command-line flags, these should be added with configuration prefixes rather than globally.
With this PR .bazelrc is created from template file and removed from git tree.

Comment thread bazel_defaults
build --genrule_strategy=standalone
build -c opt

#build --spawn_strategy=standalone

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samikama why commenting out these?

@samikama samikama Oct 11, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having -c opt forces bazel to do opt builds preventing users from having debug builds. Users need to edit .bazelrc to be able to debug. AFAIK default of bazel is fastbuild which is pretty close to opt. --spawn_strategy default is sandboxed where it can and standalone if sandboxing doesn't work. is there a strong reason against sandboxing? AFAIK this was default before this file was added.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fastbuild is not close to opt, it disables most optimizations (builds fast, runs slow).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can always to --copt=-g to add the debug symbols.
This does not prevent you from having debug builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinwicke, you are right, standing corrected. But what is going to happen if user wants to do a debug build? Isn't it better to specify this flag from the command-line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gunan, can you try with removing the flag from .bazelrc? in my case it seems to default to opt. Anyway, I can add it back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I remove build -c opt line from my bazelrc, this is what I see in subcommands:

/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 -MD -MF ...

So I do not think it defaults to -c opt`

@samikama samikama Oct 11, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gunan,
That is interesting. That is what I see

/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 '-std=c++0x' -MD -MF bazel-out/host/bin/tensorflow/cc/_objs/cc_ops/tensorflow/cc/ops/no_op.pic.d ....

The command-line you put is not for an external right? Anyway, pushed with always -c opt enabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that you have a bazelrc at your home folder, or a system level bazelrc file that changes your defaults?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure that is not the case but started from scratch again. Regardless, I added the flag back.

@martinwicke

Copy link
Copy Markdown
Member

@gunan I remembered we enabled sandboxing for ourselves, but did we consciously turn it off for others? It does tend to cause trouble.

Is this really a mistake or do we need it to avoid having to run configure?

@gunan

gunan commented Oct 11, 2018

Copy link
Copy Markdown
Contributor

@perfinion @meteorcloudy @angersson as they were involved in moving bazelrc from under tools to root.

@martinwicke I do not think we ever successfully enabled sandboxing across the board.
I am not aware of any issues that can cause for running configure.

@perfinion

Copy link
Copy Markdown
Member

.bazelrc was moved in #21374
My plan is to wait till 0.18.0 is released (should be monday) since it has try-import then bump the min version to 0.18.0 and add "try-import %workspace%/.tf_configure.bazelrc" and remove the bit in ./configure.py that edits the file.

If waiting till monday doesn't work tho, this still isn't the best way to fix it.
It looks like 0.18.0-rc9 temporarily added back parsing of tools/bazel.rc (bazelbuild/bazel#6321). So we could move .bazelrc back to tools/ now and then when 0.18.0 is out we re-do this and use "try-import .tf_configure.bazelrc" and "try-import .bazelrc.user". This bazelrc cleanup is definitely good long term its unfortunately a bit of a mess during the transition. I'd rather just get it all over with asap tho.

Comment thread bazel_defaults
# Default paths for TF_SYSTEM_LIBS
#build --define=PREFIX=/usr
#build --define=LIBDIR=$(PREFIX)/lib
#build --define=INCLUDEDIR=$(PREFIX)/include

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't comment these either, they'll break system libs stuff. The ./configure script is already setup to handle overrides for these. These are needed as the default fallback for when the user chooses not to override them.

@perfinion perfinion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open a PR soon with how this bazelrc stuff should look at the end of the day once bazel-0.18.0 is out. Then we decide either to wait till monday or go via tools/bazel.rc temporarily.

Comment thread configure.py
open(_TF_BAZELRC, 'w').close()
bazelrc_path = os.path.join(_TF_WORKSPACE_ROOT, '.bazelrc')

bazel_defaults_path = os.path.join(_TF_WORKSPACE_ROOT, 'bazel_defaults')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is this breaks building when ./configure is not run, which we're supposed to support

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand that. You mean I can just do checkout, call bazel build //tensorflow/tools/pip_package:build_pip_package and this is expected to give a fully functional TF?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah pretty much. I don't use it that way but a lot of people do and its gotta be supported.

perfinion added a commit to perfinion/tensorflow that referenced this pull request Oct 14, 2018
Bazel-0.18.0 adds a try-import option that will non-fatally try and
import a file. Use this for the configure options so that .bazelrc does
not need to change. ./configure rewriting .bazelrc makes using the git
repo annoying because the file is changed.

Also optionally import a /.bazelrc.user file that is gitignored so
user-specific options can go in there.

Fixes: tensorflow#22762
Fixes: tensorflow#22906
Signed-off-by: Jason Zaman <[email protected]>
perfinion added a commit to perfinion/tensorflow that referenced this pull request Oct 14, 2018
This reverts commit a74a321.

Bazel-0.18.0 is changing where it searches for .bazelrc files.
Originally it was removing /tools/bazel.rc and only using /.bazelrc.
This causes issues for gitignoring /.bazelrc and 0.18.0 has temporarily
added tools/bazel.rc back to the list until 0.19. The long term solution
is to use try-import but that statement is new in 0.18 and we are not
going to bump TF's minimum right away. When 0.19 is out things will need
to be changed back and the minimum bumped to 0.18.

Fixes: tensorflow#22762
Fixes: tensorflow#22906
Signed-off-by: Jason Zaman <[email protected]>
perfinion added a commit to perfinion/tensorflow that referenced this pull request Nov 8, 2018
Bazel-0.18.0 adds a try-import option that will non-fatally try and
import a file. Use this for the configure options so that .bazelrc does
not need to change. ./configure rewriting .bazelrc makes using the git
repo annoying because the file is changed.

Also optionally import a /.bazelrc.user file that is gitignored so
user-specific options can go in there.

Fixes: tensorflow#22762
Fixes: tensorflow#22906
Signed-off-by: Jason Zaman <[email protected]>
perfinion added a commit to perfinion/tensorflow that referenced this pull request Dec 5, 2018
Bazel-0.18.0 adds a try-import option that will non-fatally try and
import a file. Use this for the configure options so that .bazelrc does
not need to change. ./configure rewriting .bazelrc makes using the git
repo annoying because the file is changed.

The allowed bazel range is now 0.18.0-0.20.0 inclusive. The env var
TF_IGNORE_MAX_BAZEL_VERSION can be set to skip the max bazel version
check.

Also optionally import a /.bazelrc.user file that is gitignored so
user-specific options can go in there.

Fixes: tensorflow#22762
Fixes: tensorflow#22906
Signed-off-by: Jason Zaman <[email protected]>
perfinion added a commit to perfinion/tensorflow that referenced this pull request Dec 5, 2018
Bazel-0.18.0 adds a try-import option that will non-fatally try and
import a file. Use this for the configure options so that .bazelrc does
not need to change. ./configure rewriting .bazelrc makes using the git
repo annoying because the file is changed.

The allowed bazel range is now 0.18.0-0.20.0 inclusive. The env var
TF_IGNORE_MAX_BAZEL_VERSION can be set to skip the max bazel version
check.

Also optionally import a /.bazelrc.user file that is gitignored so
user-specific options can go in there.

Fixes: tensorflow#22762
Fixes: tensorflow#22906
Signed-off-by: Jason Zaman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants