Tcl Library Source Code

View Ticket
Login
2022-06-10
12:38 • Ticket [935ac3b65b] tcllibc 1.21 sha256 compile fails with MS C status still Open with 4 other changes artifact: 5acaadfda1 user: apnadkarni
07:26 • New ticket [935ac3b65b]. artifact: 3e448f6f98 user: apnadkarni

Ticket UUID: 935ac3b65b3e40483a22caebb61222b6aa18a35e
Title: tcllibc 1.21 sha256 compile fails with MS C
Type: Bug Version: 1.21
Submitter: apnadkarni Created on: 2022-06-10 07:26:30
Subsystem: (unused) Assigned To:
Priority: 5 Medium Severity: Important
Status: Open Last Modified: 2022-06-10 12:38:26
Resolution: None Closed By: nobody
    Closed on:
Description:
The actual error:

```
Fri Jun 10 12:07:10 IST 2022 - D:/tcl/magic/lib/tcllib1.21/sha1/sha256c.tcl

cl
	-nologo
	-c
	-DTCL_BYTE_ORDER=1234
	-DBUILD_sha256c
	-DUSE_THREAD_ALLOC=1
	-D_REENTRANT=1
	-D_THREAD_SAFE=1
	-DHAVE_PTHREAD_ATTR_SETSTACKSIZE=1
	-DHAVE_READDIR_R=1
	-DTCL_THREADS=1
	-DUSE_TCL_STUBS
	-ID:/ashok/Documents/.critcl/win32-x86_64/tcl8.4
	-ID:/ashok/Documents/.critcl/win32-x86_64
	-ID:/tcl/magic/lib/tcllib1.21/sha1
	-FoD:/ashok/Documents/.critcl/win32-x86_64/v3118_d5dc2c58245d89dba01c62678a3691eb_pic.obj
	D:/ashok/Documents/.critcl/win32-x86_64/v3118_d5dc2c58245d89dba01c62678a3691eb.c
	-W3
	-O2
	-MD
	-GS
	-fp:strict
	-DNDEBUG

v3118_d5dc2c58245d89dba01c62678a3691eb.c
D:/ashok/Documents/.critcl/win32-x86_64\sha256c/sha256cDecls.h(40): error C2375: 'SHA256Init': redefinition; different linkage
d:\ashok\documents\.critcl\win32-x86_64\sha256c\sha256.h(78): note: see declaration of 'SHA256Init'
D:/ashok/Documents/.critcl/win32-x86_64\sha256c/sha256cDecls.h(42): error C2375: 'SHA256Update': redefinition; different linkage
d:\ashok\documents\.critcl\win32-x86_64\sha256c\sha256.h(79): note: see declaration of 'SHA256Update'
D:/ashok/Documents/.critcl/win32-x86_64\sha256c/sha256cDecls.h(45): error C2375: 'SHA256Final': redefinition; different linkage
d:\ashok\documents\.critcl\win32-x86_64\sha256c\sha256.h(80): note: see declaration of 'SHA256Final'

ERROR while compiling code in D:/tcl/magic/lib/tcllib1.21/sha1/sha256c.tcl:
child process exited abnormally

critcl build failed (D:/tcl/magic/lib/tcllib1.21/sha1/sha256c.tcl)
```

The problem seems to be that the stubs declaration prototypes are generated as

```
EXTERN void		SHA256Init(SHA256Context *sc);
/* 1 */
EXTERN void		SHA256Update(SHA256Context *sc, const void *data,
				uint32_t len);
/* 2 */
EXTERN void		SHA256Final(SHA256Context *sc, uint8_t *hash);

```

(so with dll external linkage) while the sha256.h BSD file defines them as

```
void SHA256Init (SHA256Context *sc);
void SHA256Update (SHA256Context *sc, const void *data, uint32_t len);
void SHA256Final (SHA256Context *sc, uint8_t hash[SHA256_HASH_SIZE]);
```

(i.e. internal linkage).

/Ashok
User Comments: apnadkarni added on 2022-06-10 12:38:26:
I've committed a patch to sha256-vc-fix branch.

I'm not entirely happy with the patch as I don't think duplicating declarations is ever a good idea. But given the conflicting definition is dynamically generated as part of stubs I'm not sure what the correct solution is and don't have the time to go into it further.