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: add .rc support to autotools builds #9521

Closed
wants to merge 2 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Sep 16, 2022

After this update autotools builds will compile and link .rc resources
to Windows executables. Bringing this feature on par with CMake
and Makefile.m32 builds. And also making it unnecessary to improvise
these steps manually, while monkey patching build files, e.g. [0].

You can customize the resource compiler via the RC envvar, and its
options via RCFLAGS.

This harmless warning may appear throughout the build, even though the
autotools manual documents [1] RC as a valid tag:
libtool: error: ignoring unknown tag RC

[0] https://github.com/curl/curl-for-win/blob/535f19060d4b708f72e75dd849409ce50baa1b84/curl-autotools.sh#L376-L382
[1] https://www.gnu.org/software/libtool/manual/html_node/Tags.html

Closes #9521

@vszakats vszakats added build Windows Windows-specific labels Sep 16, 2022
@vszakats vszakats marked this pull request as draft September 16, 2022 22:28
@vszakats vszakats changed the title windows: add .rc support to autotools builds [WIP] windows: add .rc support to autotools builds Sep 16, 2022
@vszakats
Copy link
Member Author

vszakats commented Sep 16, 2022

There is a warning libtool: error: ignoring unknown tag RC. Seems harmless. Reason undiscovered.

@vszakats vszakats changed the title [WIP] windows: add .rc support to autotools builds windows: add .rc support to autotools builds Sep 16, 2022
@vszakats
Copy link
Member Author

CI seems fine now, with two unrelated (flaky?) single-test failures @ AppVeyor, and curl/check (@ Zuul) failing, which does fail with mostly all commits these days.

@vszakats
Copy link
Member Author

vszakats commented Sep 18, 2022

FWIW, tried removing --tag=RC to avoid the nonsense libtool warning error: ignoring unknown tag RC, which resulted in this:

libtool: compile: unable to infer tagged configuration
libtool:   error: specify a tag with '--tag'

¯\(ツ)

@vszakats vszakats closed this in 6de7322 Sep 18, 2022
@vszakats vszakats deleted the am-rc branch September 18, 2022 12:09
@monnerat
Copy link
Contributor

A side effect of this commit is new warning messages from autoreconf -fi:

configure.ac:125: warning: AC_PROG_CC was called before XC_CHECK_PROG_CC
m4/xc-cc-check.m4:86: XC_CHECK_PROG_CC is expanded from...
configure.ac:125: the top level
configure.ac:352: warning: LT_LANG was called before LT_INIT
/usr/share/aclocal/libtool.m4:61: LT_INIT is expanded from...
m4/xc-lt-iface.m4:442: XC_LIBTOOL is expanded from...
configure.ac:352: the top level
configure.ac:125: warning: AC_PROG_CC was called before XC_CHECK_PROG_CC
m4/xc-cc-check.m4:86: XC_CHECK_PROG_CC is expanded from...
configure.ac:125: the top level
configure.ac:352: warning: LT_LANG was called before LT_INIT
/usr/share/aclocal/libtool.m4:61: LT_INIT is expanded from...
m4/xc-lt-iface.m4:442: XC_LIBTOOL is expanded from...
configure.ac:352: the top level
configure.ac:125: warning: AC_PROG_CC was called before XC_CHECK_PROG_CC
m4/xc-cc-check.m4:86: XC_CHECK_PROG_CC is expanded from...
configure.ac:125: the top level
configure.ac:352: warning: LT_LANG was called before LT_INIT
aclocal.m4:83: LT_INIT is expanded from...
m4/xc-lt-iface.m4:442: XC_LIBTOOL is expanded from...
configure.ac:352: the top level

I tried locally to move the LT_LANG([Windows Resource]) after the XC_LIBTOOL and it does suppress the warnings. However I am not sure it doesn't break your commit. Can you investigate? Thanks.

@vszakats
Copy link
Member Author

vszakats commented Sep 23, 2022

@monnerat: Great find! This also fixes the odd warning noted here earlier, and in my tests the .rc files continue to compile and link fine.

Do you want to commit the fix?

[ Strangely, I'm not getting those autoreconf -fi warnings on my system. ]

@monnerat
Copy link
Contributor

Do you want to commit the fix?

No, I let you care of your baby !

Strangely, I'm not getting those autoreconf -fi warnings on my system.

libtool or autotools version dependent ? OS dependent ? who knows !

vszakats added a commit to vszakats/curl that referenced this pull request Sep 23, 2022
Follow up to 6de7322
Ref: curl#9521 (comment)

Suggested-by: Patrick Monnerat
Closes #xxxx
vszakats added a commit to vszakats/curl that referenced this pull request Sep 23, 2022
- Fix warnings when running `autoreconf -fi`.
- Fix warning when compiling .rc files:
  ```
  libtool: compile: unable to infer tagged configuration
  libtool:   error: specify a tag with '--tag'
  ```

Follow up to 6de7322
Ref: curl#9521 (comment)

Suggested-by: Patrick Monnerat
Closes #xxxx
vszakats added a commit to vszakats/curl that referenced this pull request Sep 23, 2022
Move `LT_LANG([Windows Resource])` after `XC_LIBTOOL`. This fixes:

- Warnings when running `autoreconf -fi`.

- Warning when compiling .rc files:
  libtool: compile: unable to infer tagged configuration
  libtool:   error: specify a tag with '--tag'

Follow up to 6de7322
Ref: curl#9521 (comment)

Suggested-by: Patrick Monnerat
Closes #xxxx
vszakats added a commit to vszakats/curl that referenced this pull request Sep 23, 2022
Move `LT_LANG([Windows Resource])` after `XC_LIBTOOL`, fixing:

- Warnings when running `autoreconf -fi`.

- Warning when compiling .rc files:
  libtool: compile: unable to infer tagged configuration
  libtool:   error: specify a tag with '--tag'

Follow up to 6de7322
Ref: curl#9521 (comment)

Suggested-by: Patrick Monnerat
Closes #xxxx
@vszakats
Copy link
Member Author

Sure, I've opened a PR.

libtool or autotools version dependent ? OS dependent ? who knows !

The perfect motto for autotools :) (to be fair: for build systems in general)

vszakats added a commit that referenced this pull request Sep 23, 2022
Move `LT_LANG([Windows Resource])` after `XC_LIBTOOL`, fixing:

- Warnings when running `autoreconf -fi`.

- Warning when compiling .rc files:
  libtool: compile: unable to infer tagged configuration
  libtool:   error: specify a tag with '--tag'

Follow up to 6de7322
Ref: #9521 (comment)

Suggested-by: Patrick Monnerat
Closes #9582
@monnerat
Copy link
Contributor

Thanks for fix.

jquepi pushed a commit to jquepi/curl.1.555 that referenced this pull request Oct 24, 2022
Move `LT_LANG([Windows Resource])` after `XC_LIBTOOL`, fixing:

- Warnings when running `autoreconf -fi`.

- Warning when compiling .rc files:
  libtool: compile: unable to infer tagged configuration
  libtool:   error: specify a tag with '--tag'

Follow up to 6de7322c03d5b4d91576a7d9fc893e03cc9d1057
Ref: curl/curl#9521 (comment)

Suggested-by: Patrick Monnerat
Closes #9582
@lazka
Copy link

lazka commented Oct 26, 2022

The latest release fails to build, could this be related? @vszakats

  /bin/sh ../libtool --tag=RC --mode=compile windres -I../../curl-7.86.0/include -DCURL_EMBED_MANIFEST  -i ../../curl-7.86.0/src/curl.rc -o curl.o
    CC       tool_hugehelp.o
    CC       ../lib/strtoofft.o
    CC       ../lib/timediff.o
  libtool: compile:  windres -I../../curl-7.86.0/include -DCURL_EMBED_MANIFEST -i ../../curl-7.86.0/src/curl.rc  -o .libs/curl.o
    CC       ../lib/nonblock.o
    CC       ../lib/warnless.o
    CC       ../lib/curl_multibyte.o
    CC       ../lib/version_win32.o
    CC       ../lib/dynbuf.o
    CCLD     curl.exe
  clang: error: no such file or directory: 'curl.o'
  make[2]: *** [Makefile:1011: curl.exe] Error 1

@vszakats
Copy link
Member Author

@lazka: Definitely related. So far no idea what may be happening.

Here's a relevant log from the 7.86.0 release commit CI run. That one's successful (it's a shared curl.exe):
https://dev.azure.com/daniel0244/5571c33c-81e1-43d7-93ee-d3d4152f27b2/_apis/build/builds/12347/logs/134
via
https://dev.azure.com/daniel0244/curl/_build/results?buildId=12347&view=logs&j=685797a1-fc92-54ef-6678-a6610b21db22

Here's my test log for comparison (made on fresh 7.86.0 sources. This one is a static curl.exe):

[...]
clang --target=x86_64-w64-mingw32 --sysroot=/usr/local/opt/mingw-w64/toolchain-x86_64 -DHAVE_CONFIG_H   -I../../include -I../lib -I../src -I../../lib -I../../src -DCURL_STATICLIB -D_UCRT -DNDEBUG -DHAVE_PROCESS_H -DHAS_ALPN -isystem /sandbox/gsasl/x64-ucrt/usr/include -DNGHTTP2_STATICLIB -isystem /sandbox/zlib/x64-ucrt/usr/include -isystem /sandbox/brotli/x64-ucrt/usr/include -isystem /sandbox/zstd/x64-ucrt/usr/include -isystem /sandbox/mbedtls/x64-ucrt/usr/include -isystem /sandbox/libssh2/x64-ucrt/usr/include -isystem /sandbox/nghttp2/x64-ucrt/usr/include  -O3 -Qunused-arguments -Wno-pointer-bool-conversion -pedantic -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wcast-align -Wno-system-headers -Wshorten-64-to-32 -Wunused -Wvla -Wshift-sign-overflow -Wdouble-promotion -Wcomma -Wassign-enum -Wextra-semi-stmt  -c -o ../lib/version_win32.o ../../src/../lib/version_win32.c
clang --target=x86_64-w64-mingw32 --sysroot=/usr/local/opt/mingw-w64/toolchain-x86_64 -DHAVE_CONFIG_H   -I../../include -I../lib -I../src -I../../lib -I../../src -DCURL_STATICLIB -D_UCRT -DNDEBUG -DHAVE_PROCESS_H -DHAS_ALPN -isystem /sandbox/gsasl/x64-ucrt/usr/include -DNGHTTP2_STATICLIB -isystem /sandbox/zlib/x64-ucrt/usr/include -isystem /sandbox/brotli/x64-ucrt/usr/include -isystem /sandbox/zstd/x64-ucrt/usr/include -isystem /sandbox/mbedtls/x64-ucrt/usr/include -isystem /sandbox/libssh2/x64-ucrt/usr/include -isystem /sandbox/nghttp2/x64-ucrt/usr/include  -O3 -Qunused-arguments -Wno-pointer-bool-conversion -pedantic -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wcast-align -Wno-system-headers -Wshorten-64-to-32 -Wunused -Wvla -Wshift-sign-overflow -Wdouble-promotion -Wcomma -Wassign-enum -Wextra-semi-stmt  -c -o ../lib/dynbuf.o ../../src/../lib/dynbuf.c
/bin/sh ../libtool --tag=RC --mode=compile llvm-windres -I../../include -DCURL_EMBED_MANIFEST  --target=pe-x86-64 -I/usr/local/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32/include -i ../../src/curl.rc -o curl.o
libtool: compile:  llvm-windres -I../../include -DCURL_EMBED_MANIFEST --target=pe-x86-64 -I/usr/local/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32/include -i ../../src/curl.rc -o curl.o
/bin/sh ../libtool  --tag=CC   --mode=link clang --target=x86_64-w64-mingw32 --sysroot=/usr/local/opt/mingw-w64/toolchain-x86_64  -O3 -Qunused-arguments -Wno-pointer-bool-conversion -pedantic -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wcast-align -Wno-system-headers -Wshorten-64-to-32 -Wunused -Wvla -Wshift-sign-overflow -Wdouble-promotion -Wcomma -Wassign-enum -Wextra-semi-stmt   -fuse-ld=lld -Wl,-s -static-libgcc -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup -Wl,--high-entropy-va -Wl,-Map,curl.map -L/sandbox/brotli/x64-ucrt/usr/lib -L/sandbox/zstd/x64-ucrt/usr/lib -L/sandbox/gsasl/x64-ucrt/usr/lib -L/sandbox/zlib/x64-ucrt/usr/lib -L/sandbox/brotli/x64-ucrt/usr/lib -L/sandbox/zstd/x64-ucrt/usr/lib -L/sandbox/mbedtls/x64-ucrt/usr/lib -L/sandbox/libssh2/x64-ucrt/usr/lib -L/sandbox/nghttp2/x64-ucrt/usr/lib -o curl.exe slist_wc.o tool_binmode.o tool_bname.o tool_cb_dbg.o tool_cb_hdr.o tool_cb_prg.o tool_cb_rea.o tool_cb_see.o tool_cb_wrt.o tool_cfgable.o tool_dirhie.o tool_doswin.o tool_easysrc.o tool_filetime.o tool_findfile.o tool_formparse.o tool_getparam.o tool_getpass.o tool_help.o tool_helpers.o tool_hugehelp.o tool_libinfo.o tool_listhelp.o tool_main.o tool_msgs.o tool_operate.o tool_operhlp.o tool_panykey.o tool_paramhlp.o tool_parsecfg.o tool_progress.o tool_strdup.o tool_setopt.o tool_sleep.o tool_urlglob.o tool_util.o tool_vms.o tool_writeout.o tool_writeout_json.o tool_xattr.o ../lib/strtoofft.o ../lib/timediff.o ../lib/nonblock.o ../lib/warnless.o ../lib/curl_multibyte.o ../lib/version_win32.o ../lib/dynbuf.o  curl.o ../lib/libcurl.la -lnghttp2 -lnormaliz -lssh2 -lssh2 -lgsasl -lbcrypt -ladvapi32 -lcrypt32 -lmbedtls -lmbedx509 -lmbedcrypto -lwldap32 -lzstd -lzstd -lbrotlidec -lbrotlidec -lz -lws2_32 -lucrt -lbrotlicommon -lzstd -lbcrypt 
libtool: link: clang --target=x86_64-w64-mingw32 --sysroot=/usr/local/opt/mingw-w64/toolchain-x86_64 -O3 -Qunused-arguments -Wno-pointer-bool-conversion -pedantic -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wcast-align -Wno-system-headers -Wshorten-64-to-32 -Wunused -Wvla -Wshift-sign-overflow -Wdouble-promotion -Wcomma -Wassign-enum -Wextra-semi-stmt -fuse-ld=lld -Wl,-s -static-libgcc -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable -Wl,-e -Wl,mainCRTStartup -Wl,--high-entropy-va -Wl,-Map -Wl,curl.map -o curl.exe slist_wc.o tool_binmode.o tool_bname.o tool_cb_dbg.o tool_cb_hdr.o tool_cb_prg.o tool_cb_rea.o tool_cb_see.o tool_cb_wrt.o tool_cfgable.o tool_dirhie.o tool_doswin.o tool_easysrc.o tool_filetime.o tool_findfile.o tool_formparse.o tool_getparam.o tool_getpass.o tool_help.o tool_helpers.o tool_hugehelp.o tool_libinfo.o tool_listhelp.o tool_main.o tool_msgs.o tool_operate.o tool_operhlp.o tool_panykey.o tool_paramhlp.o tool_parsecfg.o tool_progress.o tool_strdup.o tool_setopt.o tool_sleep.o tool_urlglob.o tool_util.o tool_vms.o tool_writeout.o tool_writeout_json.o tool_xattr.o ../lib/strtoofft.o ../lib/timediff.o ../lib/nonblock.o ../lib/warnless.o ../lib/curl_multibyte.o ../lib/version_win32.o ../lib/dynbuf.o curl.o  -L/sandbox/brotli/x64-ucrt/usr/lib -L/sandbox/zstd/x64-ucrt/usr/lib -L/sandbox/gsasl/x64-ucrt/usr/lib -L/sandbox/zlib/x64-ucrt/usr/lib -L/sandbox/mbedtls/x64-ucrt/usr/lib -L/sandbox/libssh2/x64-ucrt/usr/lib -L/sandbox/nghttp2/x64-ucrt/usr/lib ../lib/.libs/libcurl.a -lnghttp2 -lnormaliz -lssh2 -lgsasl -ladvapi32 -lcrypt32 -lmbedtls -lmbedx509 -lmbedcrypto -lwldap32 -lbrotlidec -lz -lws2_32 -lucrt -lbrotlicommon -lzstd -lbcrypt
 /usr/local/bin/gmkdir -p '/sandbox/curl/x64-ucrt/usr/bin'
[...]

@lazka
Copy link

lazka commented Oct 26, 2022

I've reduced it to ./configure --enable-shared --disable-static --with-schannel on current master, if that helps (we build for multiple TLS backends in MSYS2: https://packages.msys2.org/base/mingw-w64-curl)

I can also create a new issue if wanted.

@bagder
Copy link
Member

bagder commented Oct 26, 2022

I can also create a new issue if wanted.

Please do, I think we track it better that way

@vszakats
Copy link
Member Author

vszakats commented Oct 26, 2022

@lazka: Thanks! A separate Issue would be helpful indeed. --enable-shared --disable-static is the exact combination where in curl-for-win I explicitly skip building curl.exe (due to fatal ltwrapper issues post-link, and we also happen to not need this binary). This explains why this escaped my local tests. We also miss it from CI tests apparently. I could reproduce it now.

Do you have any suggestion for a fix?

On the surface the cause is libtool taking -o curl.o and translating it into -o .libs/curl.o.

@lazka
Copy link

lazka commented Oct 26, 2022

I've filed an issue at #9803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

None yet

4 participants