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

Windows: support long paths in open/mkdir/access #2969

Merged
merged 1 commit into from
Jul 24, 2017

Conversation

laszlocsomor
Copy link
Contributor

@laszlocsomor laszlocsomor commented Apr 12, 2017

This PR adds support for long paths on Windows in
open(2), mkdir(2), access(2).

Long paths are the ones longer than MAX_PATH (260
characters).

By including io_win32.h we redefine
{open,mkdir,access} to win32_{open,mkdir,access}.

Update 2017-05-04: instead of redefining open/close/etc.
I removed the win32_ prefix from the new function names
and simply import them with a using statement (if _WIN32
is defined). At the same I removed all inclusions of <io.h>
so the code can only use the functions declared in io_win32.h
and imported with using. This is a much safer approach
than the undef-define one, because this allows other
namespaces to declare functions with this name and the
preprocessor won't change those names to win32_open/etc.

These custom functions transform the path argument
to a format expected by the Windows API, then call
_w{open,mkdir,access} which understand these paths
(apparently they wrap the native widechar Windows
API functions).

This PR upstreams the fix for
bazelbuild/bazel#2634

Fixes #2891

@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure.

1 similar comment
@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure.

@laszlocsomor
Copy link
Contributor Author

@buchgr : FYI

@@ -0,0 +1,281 @@
// Protocol Buffers - Google's data interchange format
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to src/google/protobuf/stubs/.... That's where we put all base (and platform related) dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Apr 13, 2017

292fef7 was also my commit (so the CLA should be fine), just using git-bash instead of my usual git-on-msys, and the author wasn't set up properly.

bazel-io pushed a commit to bazelbuild/bazel that referenced this pull request Apr 13, 2017
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
protocolbuffers/protobuf#2969).

For instructions on how to update protobuf for bazel see
README.bazel.md.

Change-Id: I4f663955b0baeea3232b69ce32d9292427f5274a
bazel-io pushed a commit to bazelbuild/bazel that referenced this pull request Apr 14, 2017
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
protocolbuffers/protobuf#2969).

For instructions on how to update protobuf for bazel see
README.bazel.md.

Change-Id: Ic1daafe30270cb6bcc6231e6c94fb670af0475e7
@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Apr 24, 2017

Gentle ping.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Apr 24, 2017

The travis test and appveyor test are failing (seems related to this PR). Could you fix them?

buchgr added a commit to buchgr/bazel that referenced this pull request Apr 26, 2017
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
protocolbuffers/protobuf#2969.

Change-Id: Id88cd7e5b2c27ab74f3ecfa1e127e5a863f2deb3
buchgr added a commit to buchgr/bazel that referenced this pull request Apr 27, 2017
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
protocolbuffers/protobuf#2969.

Change-Id: Id88cd7e5b2c27ab74f3ecfa1e127e5a863f2deb3
buchgr added a commit to buchgr/bazel that referenced this pull request Apr 28, 2017
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
protocolbuffers/protobuf#2969.

Change-Id: Id88cd7e5b2c27ab74f3ecfa1e127e5a863f2deb3
buchgr added a commit to buchgr/bazel that referenced this pull request May 1, 2017
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
protocolbuffers/protobuf#2969.

Change-Id: Id88cd7e5b2c27ab74f3ecfa1e127e5a863f2deb3
bazel-io pushed a commit to bazelbuild/bazel that referenced this pull request May 2, 2017
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
protocolbuffers/protobuf#2969.

Change-Id: Id88cd7e5b2c27ab74f3ecfa1e127e5a863f2deb3
@laszlocsomor
Copy link
Contributor Author

PTAL -- all checks pass and I'm confident there won't be any more changes necessary (unless reviewers request so).

};

template <typename char_type>
bool has_drive_letter(const char_type* ch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This only work if checked after the long path prefix. I suggest documenting so if intentional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, intentional. Done.


template <typename char_type>
bool is_path_absolute(const std::basic_string<char_type>& path) {
return (path.size() > 2 && path[1] == ':') || has_longpath_prefix(path);
Copy link
Contributor

@damienmg damienmg May 4, 2017

Choose a reason for hiding this comment

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

replace with has_drive_letter || has_longpath_prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

static bool is_alpha(wchar_t ch) { return iswalpha(ch); }
};

template <typename char_type>
Copy link
Contributor

Choose a reason for hiding this comment

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

All those onliner should probably be declared inline (also my C++ is a bit rusty, this might already be the case for some magic).?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the compiler would auto-inline them where it can. I added the inline declarations anyway but ran into linker errors that I couldn't resolve and didn't want to spend too much time trying.

bazel-io pushed a commit to bazelbuild/bazel that referenced this pull request May 4, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 4, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 5, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
@laszlocsomor
Copy link
Contributor Author

gentle ping

hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 10, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 11, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 17, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 17, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 23, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
bazel-io pushed a commit to bazelbuild/bazel that referenced this pull request May 26, 2017
Baseline: f3ae88e

Cherry picks:
   + c58ba09:
     Release to GCS: put the final release in its own directory
   + 0acead4:
     Update protobuf to latest master at a64497c and apply
     @laszlocsomor's latest changes from
     protocolbuffers/protobuf#2969 on top of it.
   + d0242ce:
     Make symlinks consistent
   + d953ca8:
     Clean VanillaJavaBuilder output directories
   + 755669f:
     Pass all the environment variable to Bazel during bootstrapping
   + 6f04166:
     Do not mark the JDK7 installer -without-jdk-installer
   + 7205611:
     Fix #2958: Installer should not overwrite bazelrc
   + 511c35b:
     Bootstrap: move the fail function to the top
   + 8470be1:
     Clean up javac and Error Prone targets
   + 4a404de:
     Update javac version to 9-dev-r4023-2
   + 36ce4b4:
     Update javac version to 9-dev-r4023-2
   + 38949b8:
     Migrate off versioned javac and Error Prone targets
   + 1a57d29:
     Re-enabling passing -sourcepath via javacopts.
   + eb565f4:
     Make make sure that msys build actually builds msys version
   + 39f328c:
     Fix typo. Also do not override host_cpu for msvc.
   + 6248028:
     Select correct JDK for windows_msys
   + c4f271d:
     Automated g4 rollback of commit
     3e5edaf.
   + 9261809:
     Remove process-tools.cc which I forgot to delete during the last
     rollback.
   + baca6e4:
     Fix #2982: Bazel installer should not check for installed JDK if
     using a bundled JDK.
   + 866ecc8:
     Disable msys path conversion on Windows.
   + cc21998:
     Rollforward #2 of: Basic open-source crosstool to support
     targeting apple platform types.
   + 0f0ccc4:
     Escape % in strings that will appear in Crosstool
   + 3b08f77:
     Adding feature for linking C Run-Time library on Windows

Incompatible changes:

  - Bazel's Linux sandbox no longer mounts an empty tmpfs on /tmp,
    instead the existing /tmp is mounted read-write. If you prefer
    to have a tmpfs on /tmp for sandboxed actions for increased
    hermeticity, please use the flag --sandbox_tmpfs_path=/tmp.
  - Converting artifacts to strings and printing them now return
    "File" instead of "Artifact" to be consistent with the type name.
  - The return type of depset.to_list() is now a list rather than a
    frozen list. (Modifying the list has no effect on the depset.)
  - Bazel now prints logs in single lines to java.log
  - --use_dash, --dash_url and --dash_secret are removed.
  - Remote repositories must define any remote repositories they
    themselves use (e.g., if @x//:foo depends on @y//:bar, @y must be
    defined
    in @x's WORKSPACE file).
  - Remote repositories must define any remote repositories they
    themselves use (e.g., if @x//:foo depends on @y//:bar, @y must be
    defined
    in @x's WORKSPACE file).
  - objc_xcodeproj has been removed, use tulsi.bazel.build instead.

New features:

  - If grte_top is a label, it can now follow non-configurable
    redirects.
  - Optional coverage_files attribute to cc_toolchain
  - "query --output=build" now includes select()s
  - Raw LLVM profiles are now supported.

Important changes:

  - Automatically generate Proguard mapping when resource shrinking
    and Proguard are enabled.
  - New rules in Bazel: proto_library, java_lite_proto_library,
    java_proto_library and cc_proto_library
  - Activate the "dead_strip" feature if objc binary stripping is
    enabled.
  - More stable naming scheme for lambda classes in desugared android
    code
  - Convert --use_action_cache to a regular option
  - Per-architecture dSYM binaries are now propagated by
    apple_binary's AppleDebugOutputsProvider.
  - Avoid factory methods when desugaring stateless lambdas for
    Android
  - desugar calls to Objects.requireNonNull(Object o) with
    o.getClass() for android
  - Add an --copy_bridges_from_classpath argument to android
    desugaring tool
  - Change how desugar finds desugared classes to have it working on
    Windows
  - Evaluation of commands on TargetsBelowDirectory patterns
    (e.g. //foo/...) matching packages that fail to load now report
    more
    detailed error messages in keep_going mode.
  - Allow to have several inputs and outputs
  - Repository context's execute() function can print stdout/stderr
    while running. To enable, pass quiet=False.
  - Bazel can now be built with a bundled version of the OpenJDK.
    This makes it possible to use Bazel on systems without a JDK, or
    where
    the installed JDK is too old.
  - The --jobs flag now defaults to "auto", which causes Bazel to
    use a reasonable degree of parallelism based on the local
    machine's
    capacity.
  - Bazel benchmark (perf.bazel.build) supports Java and Cpp targets.
  - no factory methods generated for lambda expressions on android
  - The Linux sandbox no longer changes the user to 'nobody' by
    default, instead the current user is used as is. The old behavior
    can be
    restored via the --sandbox_fake_username flag.
  - /tmp and /dev/shm are now writable by default inside the
    Linux sandbox.
  - Bazel can now use the process-wrapper + symlink tree based
    sandbox implementation in FreeBSD.
  - turn on --experimental_incremental_dexing_error_on_missed_jars by
    default.
  - All android_binarys are now signed with both Apk Signature V1 and
    V2. See https://source.android.com/security/apksigning/v2.html
    for more details.
  - Windows MSVC wrappers: Not filtering warning messages anymore,
    use --copt=-w and --host_copt=-w to suppress them.
  - A downloader bug was fixed that prevented RFC 7233 Range
    connection resumes from working with certain HTTP servers
  - Introduces experimental android_device rule for configuring and
    launching Android emulators.
  - For boolean flags, setting them to false using --no_<flag_name>
    is deprecated. Use --no<flag_name> without the underscore, or
    --<flag_name>=false instead.
  - Add --experimental_android_compress_java_resources flag to store
    java
    resources as compressed inside the APK.
  - Removed --experimental_use_jack_for_dexing and libname.jack
    output of
    android_library.
  - blaze canonicalize-flags now takes a --show_warnings flag
  - Changing --invocation_policy will no longer force a server
    restart.
  - Bazel now supports Android NDK14.
  - android_binary multidex should now work without additional flags.
  - Use action_config in crosstool for static library archiving,
    remove ar_flag.
  - new option for bazel canonicalize-flags, --canonicalize_policy
  - Use action_config in crosstool for static library archiving,
    remove ar_flag.
  - android_library exports_manifest now defaults to True.
  - Fix select condition intersections.
  - Adds a --override_repository option that takes a repository
    name and path. This forces Bazel to use the directory at that path
    for the repository. Example usage:
    `--override_repository=foo=/home/user/gitroot/foo`.
  - fix idempotency issue with desugaring lambdas in interface
    initializers for android
  - --experimental_android_use_singlejar_for_multidex is now a no-op
    and will eventually be removed.
  - Every local_repository now requires a WORKSPACE file.
  - Remove jack and jill attributes of the android_sdk rule.
  - Add Skylark stubs needed to remove sysroot from CppConfiguration.
  - Desugar try-with-resources so that this language feature is
    available
    to deveces with API level under 19.
  - The flag --worker_max_retries was removed. The
    WorkerSpawnStrategy no longer retries execution of failed Spawns,
    the reason being that this just masks compiler bugs and isn't
    done for any other execution strategy either.
  - Bazel will no longer gracefully restart workers that crashed /
    quit, instead this triggers a build failure.
  - All java resources are now compressed in android_binary APKs by
    default.
  - All java resources are now compressed in android_binary APKs by
    default.
  - android_ndk_repository now creates a cc_library
    (@androidndk//:cpufeatures) for the cpufeatures library that is
    bundled in the Android NDK. See
    https://developer.android.com/ndk/guides/cpu-features.html for
    more details.
  - 'output_groups' and 'instrumented_files' cannot be specified in
    DefaultInfo.
  - You can increase the CPU reservation for tests by adding a
    "cpu:<n>" (e.g. "cpu:4" for four cores) tag to their rule in a
    BUILD file. This can be used if tests would otherwise overwhelm
    your system if there's too much parallelism.
  - Deprecate use_singlejar_for_proguard_libraryjars and force
    behavior to always on.
damienmg pushed a commit to bazelbuild/bazel that referenced this pull request May 26, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
juhalindfors pushed a commit to juhalindfors/bazel-patches that referenced this pull request May 27, 2017
Baseline: f3ae88e

Cherry picks:
   + c58ba09:
     Release to GCS: put the final release in its own directory
   + 0acead4:
     Update protobuf to latest master at a64497c and apply
     @laszlocsomor's latest changes from
     protocolbuffers/protobuf#2969 on top of it.
   + d0242ce:
     Make symlinks consistent
   + d953ca8:
     Clean VanillaJavaBuilder output directories
   + 755669f:
     Pass all the environment variable to Bazel during bootstrapping
   + 6f04166:
     Do not mark the JDK7 installer -without-jdk-installer
   + 7205611:
     Fix bazelbuild#2958: Installer should not overwrite bazelrc
   + 511c35b:
     Bootstrap: move the fail function to the top
   + 8470be1:
     Clean up javac and Error Prone targets
   + 4a404de:
     Update javac version to 9-dev-r4023-2
   + 36ce4b4:
     Update javac version to 9-dev-r4023-2
   + 38949b8:
     Migrate off versioned javac and Error Prone targets
   + 1a57d29:
     Re-enabling passing -sourcepath via javacopts.
   + eb565f4:
     Make make sure that msys build actually builds msys version
   + 39f328c:
     Fix typo. Also do not override host_cpu for msvc.
   + 6248028:
     Select correct JDK for windows_msys
   + c4f271d:
     Automated g4 rollback of commit
     3e5edaf.
   + 9261809:
     Remove process-tools.cc which I forgot to delete during the last
     rollback.
   + baca6e4:
     Fix bazelbuild#2982: Bazel installer should not check for installed JDK if
     using a bundled JDK.
   + 866ecc8:
     Disable msys path conversion on Windows.
   + cc21998:
     Rollforward bazelbuild#2 of: Basic open-source crosstool to support
     targeting apple platform types.
   + 0f0ccc4:
     Escape % in strings that will appear in Crosstool
   + 3b08f77:
     Adding feature for linking C Run-Time library on Windows

Incompatible changes:

  - Bazel's Linux sandbox no longer mounts an empty tmpfs on /tmp,
    instead the existing /tmp is mounted read-write. If you prefer
    to have a tmpfs on /tmp for sandboxed actions for increased
    hermeticity, please use the flag --sandbox_tmpfs_path=/tmp.
  - Converting artifacts to strings and printing them now return
    "File" instead of "Artifact" to be consistent with the type name.
  - The return type of depset.to_list() is now a list rather than a
    frozen list. (Modifying the list has no effect on the depset.)
  - Bazel now prints logs in single lines to java.log
  - --use_dash, --dash_url and --dash_secret are removed.
  - Remote repositories must define any remote repositories they
    themselves use (e.g., if @x//:foo depends on @y//:bar, @y must be
    defined
    in @x's WORKSPACE file).
  - Remote repositories must define any remote repositories they
    themselves use (e.g., if @x//:foo depends on @y//:bar, @y must be
    defined
    in @x's WORKSPACE file).
  - objc_xcodeproj has been removed, use tulsi.bazel.build instead.

New features:

  - If grte_top is a label, it can now follow non-configurable
    redirects.
  - Optional coverage_files attribute to cc_toolchain
  - "query --output=build" now includes select()s
  - Raw LLVM profiles are now supported.

Important changes:

  - Automatically generate Proguard mapping when resource shrinking
    and Proguard are enabled.
  - New rules in Bazel: proto_library, java_lite_proto_library,
    java_proto_library and cc_proto_library
  - Activate the "dead_strip" feature if objc binary stripping is
    enabled.
  - More stable naming scheme for lambda classes in desugared android
    code
  - Convert --use_action_cache to a regular option
  - Per-architecture dSYM binaries are now propagated by
    apple_binary's AppleDebugOutputsProvider.
  - Avoid factory methods when desugaring stateless lambdas for
    Android
  - desugar calls to Objects.requireNonNull(Object o) with
    o.getClass() for android
  - Add an --copy_bridges_from_classpath argument to android
    desugaring tool
  - Change how desugar finds desugared classes to have it working on
    Windows
  - Evaluation of commands on TargetsBelowDirectory patterns
    (e.g. //foo/...) matching packages that fail to load now report
    more
    detailed error messages in keep_going mode.
  - Allow to have several inputs and outputs
  - Repository context's execute() function can print stdout/stderr
    while running. To enable, pass quiet=False.
  - Bazel can now be built with a bundled version of the OpenJDK.
    This makes it possible to use Bazel on systems without a JDK, or
    where
    the installed JDK is too old.
  - The --jobs flag now defaults to "auto", which causes Bazel to
    use a reasonable degree of parallelism based on the local
    machine's
    capacity.
  - Bazel benchmark (perf.bazel.build) supports Java and Cpp targets.
  - no factory methods generated for lambda expressions on android
  - The Linux sandbox no longer changes the user to 'nobody' by
    default, instead the current user is used as is. The old behavior
    can be
    restored via the --sandbox_fake_username flag.
  - /tmp and /dev/shm are now writable by default inside the
    Linux sandbox.
  - Bazel can now use the process-wrapper + symlink tree based
    sandbox implementation in FreeBSD.
  - turn on --experimental_incremental_dexing_error_on_missed_jars by
    default.
  - All android_binarys are now signed with both Apk Signature V1 and
    V2. See https://source.android.com/security/apksigning/v2.html
    for more details.
  - Windows MSVC wrappers: Not filtering warning messages anymore,
    use --copt=-w and --host_copt=-w to suppress them.
  - A downloader bug was fixed that prevented RFC 7233 Range
    connection resumes from working with certain HTTP servers
  - Introduces experimental android_device rule for configuring and
    launching Android emulators.
  - For boolean flags, setting them to false using --no_<flag_name>
    is deprecated. Use --no<flag_name> without the underscore, or
    --<flag_name>=false instead.
  - Add --experimental_android_compress_java_resources flag to store
    java
    resources as compressed inside the APK.
  - Removed --experimental_use_jack_for_dexing and libname.jack
    output of
    android_library.
  - blaze canonicalize-flags now takes a --show_warnings flag
  - Changing --invocation_policy will no longer force a server
    restart.
  - Bazel now supports Android NDK14.
  - android_binary multidex should now work without additional flags.
  - Use action_config in crosstool for static library archiving,
    remove ar_flag.
  - new option for bazel canonicalize-flags, --canonicalize_policy
  - Use action_config in crosstool for static library archiving,
    remove ar_flag.
  - android_library exports_manifest now defaults to True.
  - Fix select condition intersections.
  - Adds a --override_repository option that takes a repository
    name and path. This forces Bazel to use the directory at that path
    for the repository. Example usage:
    `--override_repository=foo=/home/user/gitroot/foo`.
  - fix idempotency issue with desugaring lambdas in interface
    initializers for android
  - --experimental_android_use_singlejar_for_multidex is now a no-op
    and will eventually be removed.
  - Every local_repository now requires a WORKSPACE file.
  - Remove jack and jill attributes of the android_sdk rule.
  - Add Skylark stubs needed to remove sysroot from CppConfiguration.
  - Desugar try-with-resources so that this language feature is
    available
    to deveces with API level under 19.
  - The flag --worker_max_retries was removed. The
    WorkerSpawnStrategy no longer retries execution of failed Spawns,
    the reason being that this just masks compiler bugs and isn't
    done for any other execution strategy either.
  - Bazel will no longer gracefully restart workers that crashed /
    quit, instead this triggers a build failure.
  - All java resources are now compressed in android_binary APKs by
    default.
  - All java resources are now compressed in android_binary APKs by
    default.
  - android_ndk_repository now creates a cc_library
    (@androidndk//:cpufeatures) for the cpufeatures library that is
    bundled in the Android NDK. See
    https://developer.android.com/ndk/guides/cpu-features.html for
    more details.
  - 'output_groups' and 'instrumented_files' cannot be specified in
    DefaultInfo.
  - You can increase the CPU reservation for tests by adding a
    "cpu:<n>" (e.g. "cpu:4" for four cores) tag to their rule in a
    BUILD file. This can be used if tests would otherwise overwhelm
    your system if there's too much parallelism.
  - Deprecate use_singlejar_for_proguard_libraryjars and force
    behavior to always on.
hlopko pushed a commit to bazelbuild/bazel that referenced this pull request May 31, 2017
… latest changes from protocolbuffers/protobuf#2969 on top of it.

Change-Id: Ie49c5dcac06e370c5ab3863dc061513531ec8c0d
bazel-io pushed a commit to bazelbuild/bazel that referenced this pull request Jun 6, 2017
Baseline: f3ae88e

Cherry picks:
   + c58ba09:
     Release to GCS: put the final release in its own directory
   + 0acead4:
     Update protobuf to latest master at a64497c and apply
     @laszlocsomor's latest changes from
     protocolbuffers/protobuf#2969 on top of it.
   + d0242ce:
     Make symlinks consistent
   + d953ca8:
     Clean VanillaJavaBuilder output directories
   + 755669f:
     Pass all the environment variable to Bazel during bootstrapping
   + 6f04166:
     Do not mark the JDK7 installer -without-jdk-installer
   + 7205611:
     Fix #2958: Installer should not overwrite bazelrc
   + 511c35b:
     Bootstrap: move the fail function to the top
   + 8470be1:
     Clean up javac and Error Prone targets
   + 4a404de:
     Update javac version to 9-dev-r4023-2
   + 36ce4b4:
     Update javac version to 9-dev-r4023-2
   + 38949b8:
     Migrate off versioned javac and Error Prone targets
   + 1a57d29:
     Re-enabling passing -sourcepath via javacopts.
   + eb565f4:
     Make make sure that msys build actually builds msys version
   + 39f328c:
     Fix typo. Also do not override host_cpu for msvc.
   + 6248028:
     Select correct JDK for windows_msys
   + c4f271d:
     Automated g4 rollback of commit
     3e5edaf.
   + 9261809:
     Remove process-tools.cc which I forgot to delete during the last
     rollback.
   + baca6e4:
     Fix #2982: Bazel installer should not check for installed JDK if
     using a bundled JDK.
   + 866ecc8:
     Disable msys path conversion on Windows.
   + cc21998:
     Rollforward #2 of: Basic open-source crosstool to support
     targeting apple platform types.
   + 0f0ccc4:
     Escape % in strings that will appear in Crosstool
   + 3b08f77:
     Adding feature for linking C Run-Time library on Windows
   + 3566474:
     Do not use sed -E in bootstrap/compile.sh
   + c3cf7d9:
     Reverts non-xcode-available darwin crosstool generation.

Important changes:

  - Fixes regression in 0.5.0 requiring Xcode to build C++ on OSX.
mmorearty pushed a commit to Asana/bazel that referenced this pull request Jun 6, 2017
Baseline: f3ae88e

Cherry picks:
   + c58ba09:
     Release to GCS: put the final release in its own directory
   + 0acead4:
     Update protobuf to latest master at a64497c and apply
     @laszlocsomor's latest changes from
     protocolbuffers/protobuf#2969 on top of it.
   + d0242ce:
     Make symlinks consistent
   + d953ca8:
     Clean VanillaJavaBuilder output directories
   + 755669f:
     Pass all the environment variable to Bazel during bootstrapping
   + 6f04166:
     Do not mark the JDK7 installer -without-jdk-installer
   + 7205611:
     Fix bazelbuild#2958: Installer should not overwrite bazelrc
   + 511c35b:
     Bootstrap: move the fail function to the top
   + 8470be1:
     Clean up javac and Error Prone targets
   + 4a404de:
     Update javac version to 9-dev-r4023-2
   + 36ce4b4:
     Update javac version to 9-dev-r4023-2
   + 38949b8:
     Migrate off versioned javac and Error Prone targets
   + 1a57d29:
     Re-enabling passing -sourcepath via javacopts.
   + eb565f4:
     Make make sure that msys build actually builds msys version
   + 39f328c:
     Fix typo. Also do not override host_cpu for msvc.
   + 6248028:
     Select correct JDK for windows_msys
   + c4f271d:
     Automated g4 rollback of commit
     3e5edaf.
   + 9261809:
     Remove process-tools.cc which I forgot to delete during the last
     rollback.
   + baca6e4:
     Fix bazelbuild#2982: Bazel installer should not check for installed JDK if
     using a bundled JDK.
   + 866ecc8:
     Disable msys path conversion on Windows.
   + cc21998:
     Rollforward #2 of: Basic open-source crosstool to support
     targeting apple platform types.
   + 0f0ccc4:
     Escape % in strings that will appear in Crosstool
   + 3b08f77:
     Adding feature for linking C Run-Time library on Windows
   + 3566474:
     Do not use sed -E in bootstrap/compile.sh
   + c3cf7d9:
     Reverts non-xcode-available darwin crosstool generation.

Important changes:

  - Fixes regression in 0.5.0 requiring Xcode to build C++ on OSX.
Copy link
Contributor

@xfxyjwf xfxyjwf left a comment

Choose a reason for hiding this comment

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

Please squash the commits into one (to reduce noise in revision history).

@@ -118,6 +100,14 @@ namespace compiler {
namespace {
#if defined(_WIN32) && !defined(__CYGWIN__)
static const char* kPathSeparator = ";";
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::stubs::access;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the google::protobuf::internal namespace? That's what we currently use for most other stubs headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the long silence. Done, though I moved them to google::protobuf::internal::win32, because the method names are generic enough that they might collide with similarly named functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...if they were in google::protobuf::internal, that is.

@googlebot
Copy link

CLAs look good, thanks!

@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Jul 11, 2017

Re: #2969 (review) :

Please squash the commits into one (to reduce noise in revision history).

Done.

Add implementations of open(2), mkdir(2), stat(2),
etc. that support long paths under Windows (paths
longer than MAX_PATH in <windows.h>, which is 260
characters).

The implementations are in a separate namespace
(google::protobuf::internal::win32), so they won't
collide with the standard implementations in
<io.h>, but after importing them with `using` they
can be drop-in replacements.

Fixes bazelbuild/bazel#2634
Fixes protocolbuffers#2891
@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Jul 11, 2017

And rebased on top of upstream/master (9ab7c73).

@laszlocsomor
Copy link
Contributor Author

Unfortunately ci.bazel.io no longer has the logs from that run (@damienmg : FYI) so I'd just go ahead and merge this PR and fix Bazel breakages if there are any.

@xfxyjwf xfxyjwf merged commit f15185d into protocolbuffers:master Jul 24, 2017
@buchgr
Copy link
Contributor

buchgr commented Jul 25, 2017

Congrats @laszlocsomor 👍 🎆 🍾

@tri-bao
Copy link

tri-bao commented Nov 7, 2017

Hello,

Does anybody know in which release this fix was included? I try version 3.4.0 (latest version 3.4.1 doesn't have windows compiler binary) on Windows 10 64bit and still get this error. The error like:

D:...\SomeFile.java: No such file or directory

The path is 261-characters long. Shortening the path makes the compiler work.

I checked the source code zip of version 3.4.0, it seems that it includes this patch.

Anybody facing the same problem? What are your solutions apart from shortening the path :)

@laszlocsomor
Copy link
Contributor Author

I'm not on the Protobuf team, but I assume if the files are in the 3.4.0 zip then they should have been compiled into the release binary.

The files' contents and the import statements are surrounded by #ifdef _MSV_VER ... #endif statements, meaning they'd only be compiled in if built with Visual C++.

@tri-bao Have you tried building your own protoc binary?

A workaround for path lengths is to create a junction that points to the long path, but the junction itself has a short path. Since junctions are just directories with some extra metadata in the filesystem, and the resolution happens in the kernel (I believe), this workaround works both with Command Prompt and Windows Explorer, as well as with all tools that are not longpath-aware.

@tri-bao
Copy link

tri-bao commented Nov 9, 2017

thanks @laszlocsomor , compiling with Visual Studio works! I've created a ticket #3856 for asking why the public precompiled binary was not done with Visual Studio, which makes sense for Windows

@liujisi
Copy link
Contributor

liujisi commented Nov 9, 2017

The precompiled protoc was built with mingw32 cross compiled under linux environment for various reasons: mostly for automated building process and eliminating msvc dll dependencies.

Is there anyway to support the long path also under non MSVC? The code used to be guarded by #ifdef _WIN32, and I changed it to _MSV_VER as it created redefinition of those POSIX system APIs - linux-like OS for windows also implements those syscalls. I believe it can be fixed by re-organizing the code. i.e. instead of "using io_win32::mkdir" define our own mkdir wrapper and delegate it to the one in io_win32 when _WIN32 is defined.

@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Nov 14, 2017

Hey folks, sorry for dropping the ball on this issue.

I opted for defining new implementations in a C++ namespace but using the POSIX function names for the following benefits:

  • using io_win32::mkdir drop-in replaces mkdir in the whole compilation unit by just adding that line
  • no need to replace mkdir with mkdir_wrapper
  • no need to remember calling mkdir_wrapper in new code

@pherl : Does it solve the compilation problem with MinGW if you only #include Linux system headers (such as <sys/stat.h> and <sys/types.h>) if _WIN32 is not defined?

@liujisi
Copy link
Contributor

liujisi commented Nov 14, 2017

But the downside would be having to #ifdef _WIN32 and add using directives for each new files requires those posix functions. Having the wrapper made it more explicit and avoid the breakage by including posix headers transitively that we cannot control.

Anyway this should have been fixed in 3.5.0, with changes like: https://github.com/google/protobuf/blob/3.5.x/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc#L64

bithium pushed a commit to bithium/protobuf that referenced this pull request Sep 4, 2023
Windows: support long paths in open/mkdir/access
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.

Windows: long paths are not supported
8 participants