Subject: bug#30127: ICC: 'entry point must be defined' error for shared builds on Windows

From: [email-masked]
Date: Mon, 15 Jan 2018 11:48:52 +0200

Hello everyone,

For libiconv builds using Windows ICC got error:
===============================================================
builddir="`pwd`"; cd libcharset && make all && make install-lib libdir="$builddir/lib" includedir="$builddir/lib"
make[1]: Entering directory '/c/libICONV-1.15/build/libcharset'
cd lib && make all
make[2]: Entering directory '/c/libICONV-1.15/build/libcharset/lib'
/bin/sh ../libtool --mode=link /c/libICONV-1.15/build/libcharset/../build-aux/compile icl  -Zc:wchar_t -nologo -DWIN32 -D_WIN32 -DWIN64 -D_WIN64  -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -Od -Zi -GS -DDEBUG -D_DEBUG -MDd  -o libcharset.la -rpath /c/libICONV-1.15/build/../ICC64DH/lib -version-info 1:0:0 -no-undefined localcharset.lo relocatable.lo
libtool: link: rm -fr  .libs/charset.exp
libtool: link: /usr/bin/nm -B  .libs/localcharset.obj .libs/relocatable.obj   | sed -n -e 's/^.*[        ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][   ]*\([_A-Za-z][_A-Za-z0-9]*\)\{0,1\}$/\1 \2 \2/p' | sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/' | /usr/bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | uniq > .libs/charset.exp
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([         ].*\)*$/DEF/p' -e q .libs/charset.exp`" ; then cp ".libs/charset.exp" ".libs/charset-1.dll.def"; echo ".libs\\charset-1.dll.def" > ".libs/charset-1.dll.exp"; else /usr/bin/sed -e 's/^/-link -EXPORT:/' < .libs/charset.exp > .libs/charset-1.dll.exp; fi
libtool: link:  /c/libICONV-1.15/build/libcharset/../build-aux/compile icl -o .libs\\charset-1.dll  .libs/localcharset.obj .libs/relocatable.obj   -Od    "@.libs\\charset-1.dll.exp" -Wl,-DLL,-IMPLIB:".libs\\charset.lib"
icl .libs\charset-1.dll .libs/localcharset.obj .libs/relocatable.obj -Od -Wl,-DLL,-IMPLIB:.libs\charset.lib

Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0.1.156 Build 20171018
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.
icl: command line warning #10157: ignoring option '/W'; argument is of wrong type

Microsoft (R) Incremental Linker Version 14.12.25830.2
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:.libs\charset-1.dll
-EXPORT:DllMain
-EXPORT:__local_stdio_printf_options
-EXPORT:_vsnprintf_l
-EXPORT:_vsprintf_l
-EXPORT:libcharset_relocate
-EXPORT:libcharset_set_relocation_prefix
-EXPORT:locale_charset
-EXPORT:sprintf
-EXPORT:DllMain
-EXPORT:__local_stdio_printf_options
-EXPORT:_vsnprintf_l
-EXPORT:_vsprintf_l
-EXPORT:libcharset_relocate
-EXPORT:libcharset_set_relocation_prefix
-EXPORT:locale_charset
-EXPORT:sprintf
.libs/localcharset.obj
.libs/relocatable.obj
   Creating library .libs\charset-1.lib and object .libs\charset-1.exp
LINK : fatal error LNK1561: entry point must be defined
make[2]: *** [Makefile:59: libcharset.la] Error 25
make[2]: Leaving directory '/c/libICONV-1.15/build/libcharset/lib'
make[1]: *** [Makefile:34: all] Error 2
make[1]: Leaving directory '/c/libICONV-1.15/build/libcharset'
make: *** [Makefile:42: lib/localcharset.h] Error 2
===============================================================

which relate to missing Windows ICC support in 'compile' (http://git.savannah.gnu.org/cgit/automake.git/tree/lib/compile) script.

Reproduced for:
- shared builds using Windows ICC,

not reproduced for:
- static builds using Windows ICC,
- shared builds using mingw-w64 and MSVC.

Environment:
  - Windows 10 x64,
  - ICC 2018 Update 1,
  - MSVC 2017 15.5.0,
  - Windows SDK 10.0.16299.15,
  - mingw-w64 x86_64 7.2.0,
  - MSYS2 x86_64 20170918,
  - libiconv 1.15.

The same error reproduced for shared builds of other OSS Projects with Autotools-based build systems.

MSYS2 (msys2.org) Project provide a fix for 'compile' script, which they distribute:
===============================================================
diff --git a/compile b/compile
index 531136b..2be28ec 100644
--- a/compile
+++ b/compile
@@ -255,7 +255,8 @@ EOF
     echo "compile $scriptversion"
     exit $?
     ;;
-  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+  icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
     func_cl_wrapper "$@"      # Doesn't return...
     ;;
 esac
===============================================================

but it's not convenient to update build system of OSS Projects before each build.
Can this fix be merged to Automake sources directly?

Best,

Alexander