PDP-10 / its

Incompatible Timesharing System
Other
857 stars 81 forks source link

Build of tv11 fails on M2 Mac #2221

Open eswenson1 opened 1 year ago

eswenson1 commented 1 year ago

Did a build, all went well (including a build pdp10-ka KA ITS), until we tried to build tv11. Got this:

/Library/Developer/CommandLineTools/usr/bin/make -C tools/tv11 tv11 CFLAGS=-O3
cc -O3   -c -o tv.o tv.c
tv.c:287:18: warning: & has lower precedence than <; < will be evaluated first [-Wparentheses]
        curbuf = (*creg & BUFMASK < NUMFBUFFERS) ? &tv->buffers[*creg & BUFMASK] : nil;
                        ^~~~~~~~~~~~~~~~~~~~~~~
tv.c:287:18: note: place parentheses around the '<' expression to silence this warning
        curbuf = (*creg & BUFMASK < NUMFBUFFERS) ? &tv->buffers[*creg & BUFMASK] : nil;
                        ^ ~~~~~~~~~~~~~~~~~~~~~
tv.c:287:18: note: place parentheses around the & expression to evaluate it first
        curbuf = (*creg & BUFMASK < NUMFBUFFERS) ? &tv->buffers[*creg & BUFMASK] : nil;
                  ~~~~~~^~~~~~~~~
tv.c:505:2: error: call to undeclared function 'writen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        writen(con->fd, largebuf, 3+8+WIDTH*HEIGHT/8);
        ^
tv.c:505:2: note: did you mean 'write'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:496:10: note: 'write' declared here
ssize_t  write(int __fd, const void * __buf, size_t __nbyte) __DARWIN_ALIAS_C(write);
         ^
tv.c:549:3: error: call to undeclared function 'writen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                writen(tv->cons[tv->omap[osw]].fd, buf, 7);
                ^
tv.c:732:3: error: call to undeclared function 'writen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                writen(con->fd, largebuf, 3+8+w*h*2);
                ^
1 warning and 3 errors generated.
make[1]: *** [tv.o] Error 1
make: *** [tools/tv11/tv11] Error 2
larsbrinkhoff commented 1 year ago

I believe this is the fix: https://github.com/aap/pdp11/pull/23

larsbrinkhoff commented 1 year ago

@eswenson1 can you verify whether the fix works for you?

eswenson1 commented 1 year ago

I don’t know. I can’t build that code:

➜  pdp11 git:(master) make
cc -Wall -Wno-parentheses -fno-diagnostics-color -fno-diagnostics-show-caret -O3   -c -o tv11.o tv11.c
clang: error: unknown argument: '-fno-diagnostics-show-caret'
make: *** [tv11.o] Error 1
➜  pdp11 git:(master)

It looks like that fix was merged to aap/pdp11 master branch. That is what I tried building.

eswenson1 commented 1 year ago

And if I build with the more generic cc command line that I see in the "its" repository when it builds tv11, I see this:

➜  pdp11 git:(master) cc -O3 -c -o tv11.o tv11.c
tv11.c:97:1: warning: incompatible redeclaration of library function 'log' [-Wincompatible-library-redeclaration]
log (char *format, ...)
^
tv11.c:97:1: note: 'log' is a builtin with type 'double (double)'
1 warning generated.
➜  pdp11 git:(master)

Note that tv.c compiles, but tv11.o gives the warning. Is that ok?

eswenson1 commented 1 year ago

I did manage to get it to compile by getting rid of the -fno-diagnostics-show-caret option, which apparently isn't available in my cc.

➜  pdp11 git:(master) cc --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

There are lots of warnings though:

cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o tv11.o tv11.c
tv11.c:97:1: warning: incompatible redeclaration of library function 'log' [-Wincompatible-library-redeclaration]
log (char *format, ...)
^
tv11.c:97:1: note: 'log' is a builtin with type 'double (double)'
1 warning generated.
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o tv.o tv.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o ka11.o ka11.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o eae.o eae.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o kw11.o kw11.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o kl11.o kl11.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o mem.o mem.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o unix.o unix.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o util.o util.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3 -o tv11 tv11.o tv.o ka11.o eae.o kw11.o kl11.o mem.o unix.o util.o -lpthread
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o u_kb11a.o u_kb11a.c
u_kb11a.c:333:6: warning: unused variable 'ircb_fjclass' [-Wunused-variable]
        int ircb_fjclass = ircb_fclass || ircb_jmp_jsr;
            ^
u_kb11a.c:334:6: warning: unused variable 'ircb_neg_b' [-Wunused-variable]
        int ircb_neg_b = (kb->c.ir&0077700) == 0005400;
            ^
u_kb11a.c:335:6: warning: unused variable 'ircb_obd_asrb_rorb' [-Wunused-variable]
        int ircb_obd_asrb_rorb = kb->grab_obd &&
            ^
u_kb11a.c:338:6: warning: unused variable 'ircb_mul_ashc_mfp' [-Wunused-variable]
        int ircb_mul_ashc_mfp = ircc_rom_dec_ena &&
            ^
u_kb11a.c:342:6: warning: unused variable 'ircb_pclass' [-Wunused-variable]
        int ircb_pclass = ircb_part_pclass || ircb_swab || ircb_movb;
            ^
u_kb11a.c:343:6: warning: unused variable 'ircb_iclass' [-Wunused-variable]
        int ircb_iclass = ircc_rom_dec_ena &&
            ^
u_kb11a.c:345:6: warning: unused variable 'ircb_kclass' [-Wunused-variable]
        int ircb_kclass = ircc_rom_dec_ena &&
            ^
u_kb11a.c:350:6: warning: unused variable 'ircc_dm0_mfp_mtp' [-Wunused-variable]
        int ircc_dm0_mfp_mtp = ircc_mfp_mtp && (kb->c.ir&0000077) == 0000000;
            ^
u_kb11a.c:351:6: warning: unused variable 'ircc_oclass' [-Wunused-variable]
        int ircc_oclass = (kb->c.ir&0170000) == 0010000 ||
            ^
u_kb11a.c:357:6: warning: unused variable 'ircd_wdin' [-Wunused-variable]
        int ircd_wdin = (kb->c.ir&0100000) == 0 || nobyte;
            ^
u_kb11a.c:359:6: warning: unused variable 'ircd_sbyn' [-Wunused-variable]
        int ircd_sbyn = ircd_byin &&
            ^
u_kb11a.c:362:6: warning: unused variable 'ircd_rtt' [-Wunused-variable]
        int ircd_rtt = kb->c.ir == 0000006;
            ^
u_kb11a.c:364:6: warning: unused variable 'ircd_iot' [-Wunused-variable]
        int ircd_iot = kb->c.ir == 0000004;
            ^
u_kb11a.c:365:6: warning: unused variable 'ircd_opcode3' [-Wunused-variable]
        int ircd_opcode3 = kb->c.ir == 0000003;
            ^
u_kb11a.c:366:6: warning: unused variable 'ircd_trap' [-Wunused-variable]
        int ircd_trap = (kb->c.ir&01777400) == 0104400;
            ^
u_kb11a.c:367:6: warning: unused variable 'ircd_emt' [-Wunused-variable]
        int ircd_emt = (kb->c.ir&01777400) == 0104000;
            ^
16 warnings generated.
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3 -o pdp1145 u_kb11a.o
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o 1105.o 1105.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o kd11b.o kd11b.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3 -o pdp1105 1105.o kd11b.o eae.o mem.o unix.o util.o
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o 1120.o 1120.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o rf11.o rf11.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o rk11.o rk11.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o dc11_fake.o dc11_fake.c
dc11_fake.c:10:7: warning: unused variable 'unit' [-Wunused-variable]
                int unit = (bus->addr>>3)&037;
                    ^
1 warning generated.
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3 -o pdp1120 1120.o ka11.o eae.o kw11.o kl11.o rf11.o rk11.o mem.o unix.o util.o dc11_fake.o
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o 1140.o 1140.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3   -c -o kd11a.o kd11a.c
cc -Wall -Wno-parentheses -fno-diagnostics-color -O3 -o pdp1140 1140.o kd11a.o kw11.o kl11.o rk11.o mem.o unix.o util.o dc11_fake.o
➜  pdp11 git:(master) ✗
larsbrinkhoff commented 1 year ago

The warnings look harmless, so I believe tv11 should work fine.

eswenson1 commented 1 year ago

Yes, but I had to get rid of that cc option in the makefile to get it to compile on the M2 Mac. So there should be some macOS conditionalization in there.

oilcan-productions commented 8 months ago

I am getting the same errors when building pdp10-ka on Mac OS, this is an Intel iMac with Venrura 13.3.6 and the latest Xcode tools.

I checked its/tools/tv11/Makefile and the -fno-diagnostics-show-caret option is not there. Still the build fails with

tv.c:287:18: warning: & has lower precedence than <; < will be evaluated first [-Wparentheses]
        curbuf = (*creg & BUFMASK < NUMFBUFFERS) ? &tv->buffers[*creg & BUFMASK] : nil;
                        ^~~~~~~~~~~~~~~~~~~~~~~
tv.c:287:18: note: place parentheses around the '<' expression to silence this warning
        curbuf = (*creg & BUFMASK < NUMFBUFFERS) ? &tv->buffers[*creg & BUFMASK] : nil;
                        ^ ~~~~~~~~~~~~~~~~~~~~~
tv.c:287:18: note: place parentheses around the & expression to evaluate it first
        curbuf = (*creg & BUFMASK < NUMFBUFFERS) ? &tv->buffers[*creg & BUFMASK] : nil;
                  ~~~~~~^~~~~~~~~
tv.c:505:2: error: call to undeclared function 'writen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        writen(con->fd, largebuf, 3+8+WIDTH*HEIGHT/8);
        ^
tv.c:505:2: note: did you mean 'write'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:496:10: note: 'write' declared here
ssize_t  write(int __fd, const void * __buf, size_t __nbyte) __DARWIN_ALIAS_C(write);
         ^
tv.c:549:3: error: call to undeclared function 'writen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                writen(tv->cons[tv->omap[osw]].fd, buf, 7);
                ^
tv.c:732:3: error: call to undeclared function 'writen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                writen(con->fd, largebuf, 3+8+w*h*2);
                ^
1 warning and 3 errors generated.

Here is the Makefile from its/tools/tv11

$ cat Makefile 
CFLAGS=-Wall -Wno-parentheses -fno-diagnostics-color -O3
#CFLAGS+=-DAUTODIAG #-pg

all: tv11 pdp1145 pdp1105 pdp1120 pdp1140

tv11: tv11.o tv.o ka11.o eae.o kw11.o kl11.o mem.o util.o
    $(CC) $(CFLAGS) -o $@ $^ -lpthread
tv11.o: 11.h ka11.h kw11.h kl11.h tv.h

pdp1145: u_kb11a.o
    $(CC) $(CFLAGS) -o $@ $^

pdp1105: 1105.o kd11b.o eae.o mem.o util.o
    $(CC) $(CFLAGS) -o $@ $^
1105.o: 11.h kd11b.h

pdp1120: 1120.o ka11.o eae.o kw11.o kl11.o rf11.o rk11.o mem.o util.o dc11_fake.o
    $(CC) $(CFLAGS) -o $@ $^
1120.o: 11.h ka11.h kw11.h kl11.h rf11.h rk11.h dc11_fake.h

pdp1140: 1140.o kd11a.o kw11.o kl11.o rk11.o mem.o util.o dc11_fake.o
    $(CC) $(CFLAGS) -o $@ $^
1140.o: 11.h kd11a.h kw11.h kl11.h rk11.h dc11_fake.h

ka11.o: 11.h ka11.h
kd11a.o: 11.h kd11a.h
kd11b.o: 11.h kd11b.h
kw11.o: 11.h kw11.h
kl11.o: 11.h kl11.h
rk11.o: 11.h rk11.h
rf11.o: 11.h rf11.h
dc11_fake.o: 11.h dc11_fake.h
eae.o: 11.h
mem.o: 11.h
util.o: 11.h

clean:
    rm *.o
oilcan-productions commented 8 months ago

After further inspection I noticed that tv.c was missing the include for util.h and util.h was also missing from the folder. I manually added those and now tv11 builds fine. It looks like https://github.com/aap/pdp11/issues/22 was not merged correctly or part of the merge was nuked later.

larsbrinkhoff commented 8 months ago

The latest master on GitHub does have the util.h include and other changes from #22/#23. But it could be that the ITS repository doesn't have the latest commit for the tv11 submodule.

oilcan-productions commented 8 months ago

[like] Mike Kostersitz reacted to your message:


From: Lars Brinkhoff @.> Sent: Friday, January 19, 2024 3:09:40 PM To: PDP-10/its @.> Cc: Mike Kostersitz @.>; Comment @.> Subject: Re: [PDP-10/its] Build of tv11 fails on M2 Mac (Issue #2221)

The latest master on GitHub does have the util.h include and other changes from #22https://github.com/PDP-10/its/issues/22/#23https://github.com/PDP-10/its/issues/23. But it could be that the ITS repository doesn't have the latest commit for the tv11 submodule.

— Reply to this email directly, view it on GitHubhttps://github.com/PDP-10/its/issues/2221#issuecomment-1900596121, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASO6P5IUUSU3ZPUBRST2QGTYPKEDJAVCNFSM6AAAAAA464MG66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBQGU4TMMJSGE. You are receiving this because you commented.Message ID: @.***>