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

faults when compiled with cygwin(64bit) #5

Open
dnprod opened this issue Mar 19, 2017 · 4 comments
Open

faults when compiled with cygwin(64bit) #5

dnprod opened this issue Mar 19, 2017 · 4 comments

Comments

@dnprod
Copy link

dnprod commented Mar 19, 2017

hi there!
i compiled this (with -DWIN64) under windows7 cygwin-64bit
it runs okay up to NeoScrypt SSE2 4-way part D integrity test passing.
but when it moves on to Scrypt SSE2 4-way part A the program faults.

i'm by no means an assember guy :) but do the Scrypt assembler routines
still need their entry sequences WIN64-izing ?
--ken

@ghostlander
Copy link
Owner

The WIN64 part is due to different register preservation and argument passing on Windows and UNIX. I'm not familiar how Cygwin manages this part, but it's possible that it needs not -DWIN64 at all.

@dnprod
Copy link
Author

dnprod commented Mar 21, 2017

without -DWIN64 the program faults immediately,
using -DWIN64 allowed it to get as far as it did.

i believe cygwin64 uses microsoft conventions for register/function usage, only thing to watch out for
is that microsoft thinks longs are 4bytes while cygwin64 thinks longs are 8bytes.
ah, here's the reference: https://cygwin.com/cygwin-ug-net/programming.html

below is ugly, because i had to use 'code' indicators to get the double underscores to show up,
otherwise this forum just boldfaces the enclosed word when it sees underscores.

for CPP usage with cygwin, both cygwin32 and cygwin64 define __CYGWIN__
however cygwin32 defines __CYGWIN32__ but interestingly enough, cygwin64 does NOT define __CYGWIN64__ (and not __CYGWIN32__ of course :) )
cygwin64 does define __x86_64__ and __LP64__

@ghostlander
Copy link
Owner

Does it work if compiled in the 32-bit mode?

@dnprod
Copy link
Author

dnprod commented Mar 23, 2017

yes, i just got that yesterday. (i had to install cygwin32 to coexist on my system and figure out the magic incantation.)
but yes, cygwin32 builds and runs the program fine with -WIN32 defined.

here is my modified build.sh scrypt if you want to see if i've done anything completely bone headed.
(and of course this forum totally mangles things regardless of using quote or code indicators. some
back-quotes are visually missing because of that.)

#!/bin/sh

grepout=mount | grep -i -e "c:/cygwin32/bin"
grstat=$? # 0=match 1=fail 2=cmderr
if [ $grstat -eq 0 ]; then
echo "Building for WIN32"
ARCHFLAGS="-m32 -DWIN32"
PROGNAME="neoscrypt32"
else
echo "Building for WIN64"
ARCHFLAGS="-DWIN64"
PROGNAME="neoscrypt64"
fi
DEFINES="-DASM -DOPT -DMINER_4WAY -DSHA256 ${ARCHFLAGS}"
CC=gcc
CFLAGS="-Wall -O2 -fomit-frame-pointer -fno-stack-protector"
LD="gcc"
LDFLAGS="-Wl,-s"

echo "$CC $CFLAGS $DEFINES -c neoscrypt.c"
$CC $CFLAGS $DEFINES -c neoscrypt.c

echo "$CC $CFLAGS $DEFINES -c neoscrypt_test.c"
$CC $CFLAGS $DEFINES -c neoscrypt_test.c

echo "$CC $DEFINES -c neoscrypt_asm.S"
$CC $DEFINES -c neoscrypt_asm.S

echo "$LD $LDFLAGS -o ${PROGNAME} neoscrypt.o neoscrypt_test.o neoscrypt_asm.o"
$LD $LDFLAGS -o ${PROGNAME} neoscrypt.o neoscrypt_test.o neoscrypt_asm.o

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

No branches or pull requests

2 participants