Skip to content

ICU-21628 MinGW/Windows incorrect build#1733

Open
LiteratimBi wants to merge 1 commit intounicode-org:mainfrom
LiteratimBi:mingw-make
Open

ICU-21628 MinGW/Windows incorrect build#1733
LiteratimBi wants to merge 1 commit intounicode-org:mainfrom
LiteratimBi:mingw-make

Conversation

@LiteratimBi
Copy link
Copy Markdown

@LiteratimBi LiteratimBi commented May 24, 2021

Checklist
  • Required: Issue filed: https://unicode-org.atlassian.net/browse/ICU-21628
  • Required: The PR title must be prefixed with a JIRA Issue number.
  • Required: The PR description must include the link to the Jira Issue, for example by completing the URL in the first checklist item
  • Required: Each commit message must be prefixed with a JIRA Issue number.
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable

Mingw* configuration/build/setup has some pitfalls:

1. pkgdata utility produces incorrect datastub filenames when LIBPREFIX is set.

With
LIBPREFIX=lib
createFileNames (from tools/pkgdata/pkgdata.cpp:926) produces liblibicu* names

2. Less important, also pkgdata utility:

--help option message contains incorrect prefixes/suffixes (from tools/pkgdata/pkgtypes.h:139)
defined at struct modes (from tools/pkgdata/pkgdata.cpp:134)

3. Default build PKGDATA_MODE (= dll ) with ENABLE_STATIC

Makefile puts libicudtXX.a static library to bindir (data/Makefile.in:201 install-local target)

4. Platform-dependant definitions of linker flags are inconsistent (example)

ICU Issue link: https://unicode-org.atlassian.net/browse/ICU-21628

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 24, 2021

CLA assistant check
All committers have signed the CLA.

@LiteratimBi

This comment has been minimized.

@LiteratimBi LiteratimBi marked this pull request as draft May 26, 2021 13:01
@LiteratimBi LiteratimBi marked this pull request as ready for review May 26, 2021 13:32
@markusicu markusicu requested a review from srl295 May 26, 2021 17:59
@jefgen
Copy link
Copy Markdown
Member

jefgen commented May 26, 2021

Thank you very much for creating this PR, signing the CLA, and also for filing a ticket! :)

To be honest, I'm not super familiar with MinGW and its conventions, so I would love if someone else with MinGW experience and expertise could help take a look at these changes.

Recently, there have been other pull-requests from a number of people that also made changes to the ICU MinGW build/config: @longnguyen2004 @autoantwort @pchemguy. (I'm mentioning them here, in case they are interested in taking a look).

I don't know if any of them would have time or not -- but if so, it would be great if they might be able to take a look at the changes in this pull request (since it also changes the MinGW build as well).

Also, I think this change will conflict with some of the changes in PR #1732.
At minimum, we'd need to resolve the merge conflicts, but I wonder if maybe the PR author could look at this change as well.

Regarding this:

  1. Platform-dependant definitions of linker flags are inconsistent

FWIW, I think the PR #1732 was also trying to fix this as well maybe.

@@ -198,7 +198,7 @@ ifneq ($(ENABLE_STATIC),)
ifeq ($(PKGDATA_MODE),dll)
# For MinGW, do we want the DLL to go in the bin location?
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 wonder if it might be worth updating this comment. Maybe it should say something that for static builds, it is put in the libdir.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed this comment to clarify target (commit)

DATA_STUBNAME = dt
COMMON_STUBNAME = uc
I18N_STUBNAME = in
LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
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.

Have you tested the static mingw build?

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.

It even fixes the static build. Awesome :)

@longnguyen2004
Copy link
Copy Markdown
Contributor

longnguyen2004 commented May 27, 2021

Hello @LiteratimBi, and thanks for making this PR!
I just did a test build with --enable-static and everything seems good so far, I'll try a build with --enable-shared.

EDIT:
Shared build looks fine for lib, but not for bin
lib folder:

icu
libicudt.dll.a
libicuin.dll.a
libicuio.dll.a
libicutest.dll.a
libicutu.dll.a
libicuuc.dll.a
pkgconfig

bin folder:

derb.exe
escapesrc.exe
genbrk.exe
genccode.exe
gencfu.exe
gencmn.exe
gencnval.exe
gendict.exe
gennorm2.exe
genrb.exe
gensprep.exe
icu-config
icuinfo.exe
icupkg.exe
libicudt69.dll
libicuin69.dll
libicuio69.dll
libicutest69.dll
libicutu69.dll
libicuuc69.dll
liblibicudt69.dll
makeconv.exe
pkgdata.exe
uconv.exe

There's an extra liblibicudt69.dll. Can you check where it comes from?

@LiteratimBi
Copy link
Copy Markdown
Author

LiteratimBi commented May 27, 2021

Hello @LiteratimBi, and thanks for making this PR!
I just did a test build with --enable-static and everything seems good so far, I'll try a build with --enable-shared.

EDIT:
Shared build looks fine for lib, but not for bin
lib folder:

icu
libicudt.dll.a
libicuin.dll.a
libicuio.dll.a
libicutest.dll.a
libicutu.dll.a
libicuuc.dll.a
pkgconfig

bin folder:

derb.exe
escapesrc.exe
genbrk.exe
genccode.exe
gencfu.exe
gencmn.exe
gencnval.exe
gendict.exe
gennorm2.exe
genrb.exe
gensprep.exe
icu-config
icuinfo.exe
icupkg.exe
libicudt69.dll
libicuin69.dll
libicuio69.dll
libicutest69.dll
libicutu69.dll
libicuuc69.dll
liblibicudt69.dll
makeconv.exe
pkgdata.exe
uconv.exe

There's an extra liblibicudt69.dll. Can you check where it comes from?

According to size, libicudt69.dll is pre-build wrapper and liblibicudt69.dll is the correct datastub

Are you shure that you using correct branch (git checkout mingw-make)?
If yes, autoconf output might be helpfull

Mine bindir looks so:

total 42368
   327900 May 27 09:23 derb.exe
   534607 May 27 09:23 escapesrc.exe
   317569 May 27 09:23 genbrk.exe
   297824 May 27 09:23 genccode.exe
   315461 May 27 09:23 gencfu.exe
   296130 May 27 09:23 gencmn.exe
   311228 May 27 09:23 gencnval.exe
   325227 May 27 09:23 gendict.exe
   398208 May 27 09:23 gennorm2.exe
   510968 May 27 09:23 genrb.exe
   311538 May 27 09:23 gensprep.exe
    25605 May 27 09:23 icu-config
   298983 May 27 09:23 icuinfo.exe
   308523 May 27 09:23 icupkg.exe
 28870610 May 27 09:23 libicudt69.dll
  4878882 May 27 09:23 libicuin69.dll
   176751 May 27 09:23 libicuio69.dll
   352897 May 27 09:23 libicutest69.dll
   772231 May 27 09:23 libicutu69.dll
  2648525 May 27 09:23 libicuuc69.dll
   348183 May 27 09:23 makeconv.exe
   344525 May 27 09:23 pkgdata.exe
   354520 May 27 09:23 uconv.exe

@LiteratimBi LiteratimBi marked this pull request as draft May 27, 2021 06:57
@longnguyen2004
Copy link
Copy Markdown
Contributor

I merged your branch on top of main. I'll try doing a build without it and see what happens.

@longnguyen2004
Copy link
Copy Markdown
Contributor

Hmm, maybe I did something wrong. I'll do some more investigation.
If anyone's interested in reproducing it, I'm cross-compiling from WSL2, using llvm-mingw.

srl295
srl295 previously approved these changes May 27, 2021
Copy link
Copy Markdown
Member

@srl295 srl295 left a comment

Choose a reason for hiding this comment

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

looks reasonable to me

@LiteratimBi LiteratimBi marked this pull request as ready for review May 27, 2021 15:22
@jira-pull-request-webhook
Copy link
Copy Markdown

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

@LiteratimBi LiteratimBi requested review from jefgen and srl295 May 27, 2021 15:27
@longnguyen2004
Copy link
Copy Markdown
Contributor

I'm still getting liblibicudt69.dll for some reason. Can someone do a cross-compile from WSL/Ubuntu and see if the problem persists?

Comment on lines 930 to 933
} else {
sprintf(libFileNames[LIB_FILE], "%s%s%s",
(strstr(libName, "icudt") ? "lib" : ""),
pkgDataFlags[LIBPREFIX],
sprintf(libFileNames[LIB_FILE], "%s%s",
(strstr(libName, "libicudt") ? "" : pkgDataFlags[LIBPREFIX]),
libName);
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.

Also add the same check to the #else case, since it fixes the problem for cross-compiling.
pkgdata --verbose output:

LD_LIBRARY_PATH=/home/KurumiGaming/icu/icu4c/source/build-native/stubdata:/home/KurumiGaming/icu/icu4c/source/build-native/tools/ctestfw:/home/KurumiGaming/icu/icu4c/source/build-native/lib:$LD_LIBRARY_PATH  /home/KurumiGaming/icu/icu4c/source/build-native/bin/pkgdata -O ../data/icupkg.inc -q -c -s /home/KurumiGaming/icu/icu4c/source/build-cross-shared/data/out/build/icudt69l -d ../lib -e icudt69  -T ./out/tmp -p icudt69l -m dll -r 69 -L libicudt  ./out/tmp/icudata.lst -v
# pkgdata: Reading ./out/tmp/icudata.lst..
# Reading options file ../data/icupkg.inc
...
# Writing package file ./out/tmp/icudt69l.dat ..
# libFileName[LIB_FILE] = liblibicudt
# libFileName[LIB_FILE_VERSION] = liblibicudt69.dll
...

...which indicates that it uses the #else case.
This is just a small part of a more general problem. As it is right now, pkgdata is really only suitable for native builds, since the platform-specific bits are being added in using macros, not by checking the host triplet.

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.

This is just a small part of a more general problem. As it is right now, pkgdata is really only suitable for native builds, since the platform-specific bits are being added in using macros, not by checking the host triplet.

Yeah this is a real problem. I build icu with vcpkg, but vcpkg sets --with-cross-build= when building mingw on windows because host-triplet=x64-windows and target-triplet=x64-mingw-static. And with --with-cross-build= the build fails because of the problem you described

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.

We can handle that on vcpkg, by not requiring the host dependency on Windows triplets. But the problem with pkgdata not suitable for cross compiling is still there, and needs to be fixed in the future.

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.

Yeah I know and I have done that locally. I only wanted to highlight that this is even a problem when you cross build from windows to mingw

@autoantwort
Copy link
Copy Markdown
Contributor

I'm still getting liblibicudt69.dll for some reason. Can someone do a cross-compile from WSL/Ubuntu and see if the problem persists?

Did you also get this problem with #1735?

@longnguyen2004
Copy link
Copy Markdown
Contributor

It seems to be less intrusive than this PR, I'll do a build today and see if it works

@autoantwort
Copy link
Copy Markdown
Contributor

It seems to be less intrusive than this PR, I'll do a build today and see if it works

Do you already have results? :)

@longnguyen2004
Copy link
Copy Markdown
Contributor

Oh sorry, I forgot to comment on this one :)
The build works fine, but as expected, the static build puts the data library in the bin folder, and is also named icudt.a, which is incorrect. This is probably a problem in pkgdata.
And the native vs cross compile problem is still present on both PR, once again due to pkgdata (remember what I said about compile-time macros?), so neither of these would be a complete fix.

@srl295
Copy link
Copy Markdown
Member

srl295 commented Jun 10, 2021

Jenkins, test this.

@autoantwort
Copy link
Copy Markdown
Contributor

@longnguyen2004 when I understand the last comments on the other pr correctly this pr has less problems than the other pr right?

@longnguyen2004
Copy link
Copy Markdown
Contributor

@longnguyen2004 when I understand the last comments on the other pr correctly this pr has less problems than the other pr right?

Yes that's correct, but this PR is also changing a lot of other things that I don't fully understand, so I say we should explore other approaches first, like fixing up pkgdata by itself, before settling on this.

@autoantwort
Copy link
Copy Markdown
Contributor

Yes that's correct, but this PR is also changing a lot of other things that I don't fully understand, so I say we should explore other approaches first, like fixing up pkgdata by itself, before settling on this.

Imho this should be merged anyway because it fixes the icu static mingw builds that are currently broken and does not build at all.

@longnguyen2004
Copy link
Copy Markdown
Contributor

@LiteratimBi Can you apply my suggestion in #1733 (comment) before moving on? This is a workaround for the cross compiling problem I had before.

@autoantwort
Copy link
Copy Markdown
Contributor

Seems like @LiteratimBi does not respond anymore

@srl295
Copy link
Copy Markdown
Member

srl295 commented Jan 6, 2023

@longnguyen2004 @autoantwort do you want to make a new PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants