[
https://issues.apache.org/jira/browse/HADOOP-19977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18111527#comment-18111527
]
ASF GitHub Bot commented on HADOOP-19977:
-----------------------------------------
GauthamBanasandra opened a new pull request, #8713:
URL: https://github.com/apache/hadoop/pull/8713
### Description of PR
Building `hadoop-common` with `-Pnative-win` fails on Windows against a
current
Windows 11 SDK:
```
winutils.h(129,7): error C2733: 'GetFileInformationByName': you cannot
overload
a function with 'extern "C"' linkage [libwinutils.vcxproj]
```
Windows SDK 10.0.26100.0 introduced its own `GetFileInformationByName` in
`WinBase.h` (guarded by `#if (NTDDI_VERSION >= NTDDI_WIN11_ZN)`). It collides
with the winutils helper of the same name that Hadoop has carried for years:
```c
/* Windows SDK 10.0.26100.0 - WinBase.h */
BOOL WINAPI GetFileInformationByName(PCWSTR, FILE_INFO_BY_NAME_CLASS, PVOID,
ULONG);
/* hadoop - winutils.h */
DWORD GetFileInformationByName(LPCWSTR pathName, BOOL followLink,
LPBY_HANDLE_FILE_INFORMATION
lpFileInformation);
```
The two differ in signature, so in C++ they would ordinarily overload. But
overloading requires C++ linkage and both have **C** linkage — `winutils.h`
wraps its declarations in `extern "C"`, and so does the SDK header — so the
compiler rejects the pair. It surfaces in `libwinutils.vcxproj`, which
compiles
`config.cpp` as C++. SDK 10.0.22621.0 does not declare the symbol, which is
why
this only now breaks.
The SDK name cannot be changed, so this renames the Hadoop helper to
`GetFileInformationByPathName`. That also reads as the by-path counterpart to
the SDK's existing `GetFileInformationByHandle`.
This is a pure rename of one internal helper plus its call sites. No
behaviour
change, and no change to any public or JNI-visible surface.
### How was this patch tested?
Built on Windows 11 with Visual Studio 2022 (toolset v143), Windows SDK
10.0.26100.0, and JDK 8, using the `native-win` profile:
- `hadoop-common` builds, producing `winutils.exe`, `hadoop.dll` and
`libwinutils.lib`.
- `hadoop-hdfs-native-client` builds, producing `hdfs.dll`.
- Full reactor `mvn install -Pdist,src,yarn-ui -Dtar -DskipTests`: BUILD
SUCCESS
across all 232 modules; the resulting `hadoop-3.5.0-SNAPSHOT.tar.gz`
contains
`bin/winutils.exe`, `bin/hadoop.dll` and `bin/hdfs.dll`.
- Smoke-tested the rebuilt binary on the renamed code path: `winutils ls
<file>`
(which calls the renamed function), `winutils chmod 754 <file>` followed by
`winutils ls`, and `winutils systeminfo` all behave as before.
### For code changes:
- [x] Does the title or this PR starts with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: have the integration tests been executed and the
endpoint
declared according to the connector-specific documentation?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in
a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
🤖 Generated with [Claude Code](https://claude.com/claude-code)
> winutils: GetFileInformationByName collides with Windows SDK 10.0.26100
> -----------------------------------------------------------------------
>
> Key: HADOOP-19977
> URL: https://issues.apache.org/jira/browse/HADOOP-19977
> Project: Hadoop Common
> Issue Type: Bug
> Components: native
> Affects Versions: 3.5.0
> Environment: Windows 10/11
> Reporter: Gautham Banasandra
> Assignee: Gautham Banasandra
> Priority: Major
> Fix For: 3.5.0
>
>
> h3. Symptom
> Building {{hadoop-common}} with {{-Pnative-win}} on Windows fails to compile
> winutils against a current Windows 11 SDK:
> {noformat}
> winutils.h(129,7): error C2733: 'GetFileInformationByName': you cannot
> overload
> a function with 'extern "C"' linkage
> [hadoop-common-project\hadoop-common\src\main\winutils\libwinutils.vcxproj]
> {noformat}
> The build stops at the {{compile-ms-winutils}} step, so no {{winutils.exe}} or
> {{hadoop.dll}} is produced and the whole native Windows build is blocked.
> h3. Root cause
> Windows SDK 10.0.26100.0 introduced its own {{GetFileInformationByName}} in
> {{WinBase.h}} (line 9397), guarded by {{#if (NTDDI_VERSION >=
> NTDDI_WIN11_ZN)}}.
> It collides with the winutils helper of the same name that Hadoop has carried
> for years:
> {code:c}
> /* Windows SDK 10.0.26100.0 - WinBase.h */
> BOOL WINAPI GetFileInformationByName(PCWSTR FileName,
> FILE_INFO_BY_NAME_CLASS
> FileInformationClass,
> PVOID FileInfoBuffer,
> ULONG FileInfoBufferSize);
> /* hadoop - winutils/include/winutils.h:129 */
> DWORD GetFileInformationByName(LPCWSTR pathName, BOOL followLink,
> LPBY_HANDLE_FILE_INFORMATION
> lpFileInformation);
> {code}
> The two differ in signature, so in C++ they would ordinarily overload. But
> overloading requires C++ linkage and both of these have *C* linkage --
> {{winutils.h}} wraps its declarations in {{extern "C"}} (winutils.h:33) and
> the
> SDK header does the same. The compiler therefore rejects the pair outright.
> It surfaces in {{libwinutils.vcxproj}}, which compiles {{config.cpp}} as C++.
> Windows SDK 10.0.22621.0 does not declare the symbol, which is why this has
> only
> started breaking recently -- it is triggered by the installed SDK version,
> not by
> any change in Hadoop.
> h3. Affected code
> {{GetFileInformationByName}} is referenced in 7 places across 5 files, all
> under
> {{hadoop-common-project/hadoop-common/src/main/winutils/}}:
> * {{include/winutils.h}} -- declaration
> * {{libwinutils.c}} -- definition, plus one call in
> {{FindFileOwnerAndPermission}}
> * {{chmod.c}}, {{hardlink.c}}, {{ls.c}} -- call sites
> h3. Proposed fix
> The SDK name cannot be changed, so rename the Hadoop helper. Suggested name is
> {{GetFileInformationByPathName}}, which also reads as the by-path counterpart
> to
> the SDK's existing {{GetFileInformationByHandle}}.
> This is a pure rename of one internal static-library helper and its call
> sites.
> There is no behaviour change, and no public or JNI-visible surface is
> affected.
> h3. To reproduce
> On Windows with Visual Studio 2022 and Windows SDK 10.0.26100.0 installed,
> from
> an x64 Native Tools Command Prompt:
> {noformat}
> mvn clean package -DskipTests -Pnative-win -Duse.platformToolsetVersion=v143 ^
> -Drequire.openssl -Dopenssl.prefix=<vcpkg>\installed\x64-windows ^
> -Dcmake.prefix.path=<vcpkg>\installed\x64-windows ^
> -Dwindows.cmake.toolchain.file=<vcpkg>\scripts\buildsystems\vcpkg.cmake ^
> -Dwindows.cmake.build.type=RelWithDebInfo -Dwindows.build.hdfspp.dll=off ^
> -Dwindows.no.sasl=on -pl hadoop-common-project/hadoop-common -am
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]