Terraspace / UASM

UASM - Macro Assembler
http://www.terraspace.co.uk/uasm.html
Other
220 stars 49 forks source link

Cannot build the latest UASM on macOS #148

Open anta40 opened 3 years ago

anta40 commented 3 years ago

I'm on macOS Big Sur, and have some C/C++ compilers installed:

After pulling the latest code from git, none of them can build UASM:

make -f ClangOSX64.mak 
gcc -D __UNIX__ -c -IH -D __UNIX__ -DNDEBUG -O2 -ansi -funsigned-char -fwritable-strings -o GccUnixR/dbgcv.o dbgcv.c
In file included from dbgcv.c:13:
H/memalloc.h:49:10: warning: 'alloca' macro redefined [-Wmacro-redefined]
        #define alloca(x)  __builtin_alloca(x)
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/alloca.h:39:9: note: previous definition is here
#define alloca(size)    __alloca(size)
        ^
In file included from dbgcv.c:14:
In file included from H/parser.h:59:
H/instruct.h:1241:10: warning: '/*' within block comment [-Wcomment]
/* #if 0 /* v2.09: added, inactive ( not supported by ML64 v8,9,10 ) */
         ^
dbgcv.c:20:10: fatal error: 'direct.h' file not found
#include <direct.h>
         ^~~~~~~~~~

So I did some adjustments on dbgcv.c:

So far, the error count is reduced into 4. I still have no idea how to solve the first 2:

dbgcv.c:1572:16: error: use of undeclared identifier '_pgmptr'
                len = strlen(_pgmptr) + 1;
                             ^
dbgcv.c:1573:17: error: use of undeclared identifier '_pgmptr'
                s = strcpy(s, _pgmptr) + len;

Seems like _pgmptr is Windows-specific.

And the last 2 are casting errors:

dbgcv.c:1582:41: error: 'char *' and 'uint_8 *' (aka 'unsigned char *') are not pointers to compatible types
                EnvBlock->reclen = (unsigned short)(s - cv.ps - 2);
                                                    ~ ^ ~~~~~
dbgcv.c:1583:9: warning: assigning to 'uint_8 *' (aka 'unsigned char *') from 'char *' converts between pointers to integer types with different sign
      [-Wpointer-sign]
                cv.ps = s;
                      ^ ~
dbgcv.c:1587:28: error: 'char *' and 'uint_8 *' (aka 'unsigned char *') are not pointers to compatible types
                cv.section->length += (s - start);
justdan96 commented 3 years ago

You may want to have a look at the changes in https://github.com/Terraspace/UASM/pull/146 and test those on your system.

anta40 commented 2 years ago

Sorry for the late very reply. As I usual, pulled the latest code git, and applied the changes mentioned in #146. Now I'm facing different error messages:

assemble.c:1180:3: error: implicit declaration of function 'AddSimdTypes' [-Werror,-Wimplicit-function-declaration] AddSimdTypes(); ^ assemble.c:1205:30: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] if ( Token_Count = Tokenize( LineStoreCurr->line, 0, ModuleInfo.tokenarray, TOK_DEFAULT ) )


assemble.c:1205:30: note: place parentheses around the assignment to silence this warning
            if ( Token_Count = Tokenize( LineStoreCurr->line, 0, ModuleInfo.tokenarray, TOK_DEFAULT ) )
                             ^
                 (                                                                                   )
assemble.c:1205:30: note: use '==' to turn this assignment into an equality comparison
            if ( Token_Count = Tokenize( LineStoreCurr->line, 0, ModuleInfo.tokenarray, TOK_DEFAULT ) )
                             ^
                             ==
assemble.c:1279:5: error: implicit declaration of function 'strupr' [-Werror,-Wimplicit-function-declaration]
    _strupr( ModuleInfo.name );
    ^
justdan96 commented 2 years ago

Do you want to try the steps from this Dockerfile I made? https://github.com/justdan96/7zip_static/blob/main/Dockerfile#L13

anta40 commented 2 years ago

Do you want to try the steps from this Dockerfile I made? https://github.com/justdan96/7zip_static/blob/main/Dockerfile#L13

I followed your steps On MacOS, seems like there's no built-in strupr(), so I took this simple implementation and put that in assemble.c

Now 1 error left:

assemble.c:1191:3: error: implicit declaration of function 'AddSimdTypes' [-Werror,-Wimplicit-function-declaration] AddSimdTypes();

darealshinji commented 2 years ago

I've added most of the fixes from the open pull requests plus a few extra ones to fix building on Linux. Maybe that also helps you to build on Mac: https://github.com/darealshinji/UASM

You should also disable all "-Werror" flags.

teoberi commented 2 years ago

Try some pull requests with your changes, maybe something will move with compiling in Linux.

darealshinji commented 2 years ago

Try some pull requests with your changes, maybe something will move with compiling in Linux.

All the important fixes are already present as PRs, the rest is just silencing compiler warnings.

teoberi commented 2 years ago

Yes I follow the development of UASM, many want to help but nothing concrete is seen.

anta40 commented 2 years ago

I've added most of the fixes from the open pull requests plus a few extra ones to fix building on Linux. Maybe that also helps you to build on Mac: https://github.com/darealshinji/UASM

You should also disable all "-Werror" flags.

Now I'm on Debian. Running make, I got this:

cc Release/main.o Release/apiemu.o Release/orgfixup.o Release/assemble.o Release/assume.o Release/atofloat.o Release/backptch.o Release/bin.o Release/branch.o Release/cmdline.o Release/codegen.o Release/codegenv2.o Release/coff.o Release/condasm.o Release/context.o Release/cpumodel.o Release/data.o Release/dbgcv.o Release/directiv.o Release/elf.o Release/end.o Release/equate.o Release/errmsg.o Release/expans.o Release/expreval.o Release/extern.o Release/fastpass.o Release/fixup.o Release/fpfixup.o Release/hll.o Release/input.o Release/invoke.o Release/label.o Release/linnum.o Release/listing.o Release/loop.o Release/lqueue.o Release/ltype.o Release/macho64.o Release/macro.o Release/macrolib.o Release/mangle.o Release/memalloc.o Release/msgtext.o Release/omf.o Release/omffixup.o Release/omfint.o Release/option.o Release/parser.o Release/posndir.o Release/preproc.o Release/proc.o Release/queue.o Release/reswords.o Release/safeseh.o Release/segment.o Release/simd.o Release/simsegm.o Release/string.o Release/symbols.o Release/tbyte.o Release/pseudoFilter.o Release/tokenize.o Release/types.o  -s -o Release/uasm -Wl,-Map,Release/uasm.map
/usr/bin/ld: Release/orgfixup.o:(.bss+0x8): multiple definition of `MODULEARCH'; Release/main.o:(.bss+0x0): first defined here
/usr/bin/ld: Release/orgfixup.o:(.bss+0x9): multiple definition of `evexflag'; Release/main.o:(.bss+0x1): first defined here
/usr/bin/ld: Release/orgfixup.o:(.bss+0xa): multiple definition of `evex'; Release/main.o:(.bss+0x2): first defined here
/usr/bin/ld: Release/orgfixup.o:(.bss+0xb): multiple definition of `broadflags'; Release/main.o:(.bss+0x3): first defined here
/usr/bin/ld: Release/orgfixup.o:(.bss+0xc): multiple definition of `decoflags'; Release/main.o:(.bss+0x4): first defined here
/usr/bin/ld: Release/assemble.o:(.bss+0x1328): multiple definition of `MODULEARCH'; Release/main.o:(.bss+0x0): first defined here
...
...
...
/usr/bin/ld: Release/types.o:(.bss+0xa): multiple definition of `evex'; Release/main.o:(.bss+0x2): first defined here
/usr/bin/ld: Release/types.o:(.bss+0xb): multiple definition of `broadflags'; Release/main.o:(.bss+0x3): first defined here
/usr/bin/ld: Release/types.o:(.bss+0xc): multiple definition of `decoflags'; Release/main.o:(.bss+0x4): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:47: Release/uasm] Error 1
darealshinji commented 2 years ago

@anta40 Strange, I cannot confirm this on Ubuntu using gcc version 9.3.0. Make uses "cc" as compiler, are you sure that this is "gcc" on your system? Are you using the latest revision of the "gcc-fixes" branch? It says the symbol "MODULEARCH" was previously defined in main.o, but in main.c there's only one instance of this symbol and it's commented out, so that doesn't make sense (the other symbols don't even appear in main.c).

Can you try to delete the "Release" directory and run it again with "CC=gcc make -f Makefile"?

cielavenir commented 2 years ago

When using v2.55, sed -i -e 's/-ansi/-Wno-error=implicit-function-declaration/' UASM-2.55/ClangOSX64.mak worked.

I published https://github.com/cielavenir/homebrew-ciel/blob/master/uasm.rb .

anta40 commented 2 years ago

sed -i -e 's/-ansi/-Wno-error=implicit-function-declaration/' UASM-2.55/ClangOSX64.mak

I just tried this using UASM 2.55 (not modified at all), and uasm built succesfully. Interestingly, it doesn't work with the very latest version on git, though.

dbgcv.c:20:10: fatal error: 'direct.h' file not found

include