Hello,

I encountered an issue with response files whilst building a shared library
with many object files.  When gcc invokes collect2 it doesn't forward the
response file (@xyz.rsp) but rather passes its contents as arguments, which
exhausts the 32KB command line length limit on Windows.

Subsequent to my message is a script to reproduce this issue, which is present
in recent builds by Ruben [1] and niXman [2].  This problem was previously
reported on the GCC bug tracker [3] and it seems the solution would be to
configure GCC with the "--with-gnu-ld" flag (untested).

Regards,

--Zaheer

[1] 
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/release/x86_64-w64-mingw32-gcc-4.6.3-release-win64_rubenvb.7z
[2] 
http://sourceforge.net/projects/mingwbuilds/files/windows-host/4.7.0/x86_64-mingw32-gcc-4.7.0-release-c,c++,fortran.7z
[3] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45749

#!/bin/bash -xe

SRC_DIR=src/abcd/efgh/ijkl/mnop/qrst/uvwx/yz
RESPONSE_FILE=objects.resp

[[ -f "$RESPONSE_FILE" ]] && rm "$RESPONSE_FILE"
[[ -d "$SRC_DIR" ]] && rm -rf "$SRC_DIR"

mkdir -p "$SRC_DIR"
# Each filename has 51 characters (+ space), so should reach 32KB
limit around 630 files.
for ((i = 1; i <= 630; i++)); do
    printf -v SRC_FILENAME "$SRC_DIR/function%04d.c" $i
    OBJ_FILENAME=${SRC_FILENAME/.c/.o}
    echo "int function$i() { return $i; }" > "$SRC_FILENAME"
    gcc -c "$SRC_FILENAME" -o "$OBJ_FILENAME"
    echo "$OBJ_FILENAME" >> "$RESPONSE_FILE"
done

# This step fails with the following error:
#     gcc.exe: error: CreateProcess: No such file or directory
gcc -v -shared -o functions.dll @$RESPONSE_FILE

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to