modula3 / cm3

Critical Mass Modula-3
http://modula3.github.io/cm3/
Other
134 stars 25 forks source link

Building on macOS Mojave 10.14.3 fails at recompiling HMTime.i3 #46

Closed brakmic closed 5 years ago

brakmic commented 5 years ago

Hi everyone,

I'm trying to compile an AMD64_DARWIN release on my Mac but it always stops at this step:

new exporters -> recompiling HMTime.i3
 -> archiving libcit_util.a
Undefined symbols for architecture x86_64:
  "_UtimeOpsC__delete_T", referenced from:
      _UtimeWrap__delete_T in UtimeWrap_m.o
  "_UtimeOpsC__make_T", referenced from:
      _UtimeWrap__make_T in UtimeWrap_m.o
  "_UtimeOpsC__check_types", referenced from:
      _UtimeOpsC_M3 in UtimeOpsC_m.o
  "_UtimeOpsC__Get_second", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Get_minute", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Get_hour", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Get_month", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Get_year", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__mktime", referenced from:
      _TZ__Mktime in TZ_m.o
  "_UtimeOpsC__Get_wday", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Set_second", referenced from:
      _TZ__Mktime in TZ_m.o
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Set_day", referenced from:
      _TZ__Mktime in TZ_m.o
  "_UtimeOpsC__Get_gmtoff", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Set_month", referenced from:
      _TZ__Mktime in TZ_m.o
  "_CTZ__setTZ", referenced from:
      _TZ__SetCurTZ in TZ_m.o
      _TZ_M3 in TZ_m.o
  "_UtimeOpsC__Get_zone", referenced from:
      _UCTime__ctime in UCTime_m.o
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__write_double_clock", referenced from:
      _UCTime__ctime in UCTime_m.o
  "_UtimeOpsC__Set_year", referenced from:
      _TZ__Mktime in TZ_m.o
  "_UtimeOpsC__Set_minute", referenced from:
      _TZ__Mktime in TZ_m.o
  "_UtimeOpsC__ctime_r", referenced from:
      _UCTime__ctime in UCTime_m.o
  "_UtimeOpsC__Get_day", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__localtime_r", referenced from:
      _UCTime__ctime in UCTime_m.o
      _TZ__Mktime in TZ_m.o
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Set_hour", referenced from:
      _TZ__Mktime in TZ_m.o
  "_diskAvail", referenced from:
      _SysPerf__DiskAvail in SysPerf_m.o
  "_getloadavg_glue", referenced from:
      _SysPerf__GetLoadAvg in SysPerf_m.o
  "_printf_prints", referenced from:
      _RTRefStats__Visit in RTRefStats_m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make_lib => 1
librarian failed building: cit_util
Fatal Error: package build failed
 *** execution of [<function _BuildGlobalFunction at 0x10f6b87d0>, <function _ShipFunction at 0x10f6b8848>] failed ***
ERROR: ./do-cm3-all.py buildship

I've properly setup the environment, with the latest available x64 compiler release for macOS. I've used boot2.py from scripts/python directory to kickoff the compilation.

I'm not sure if there are any alternative ways to compile the toolchain.

Kind regards,

mikanystrom commented 5 years ago

Well all right, I have an idea what's going on here but I am not entirely sure.

I uploaded a bunch of updates to the caltech-parser area a few weeks ago. What you're seeing there is mostly references to symbols defined there. There is some stuff I don't recognize but it's been years since I dug into it.

BUT... I am currently on a machine that has a cm3 distribution that's nearly a year old on it. It's AMD64_LINUX. It was able to build the head without trouble. I used the following commands:

14  7:43    git checkout master
15  7:43    git pull

... 27 7:55 set path= ( /usr/cm3/bin $path ) 28 7:55 setenv CM3 which cm3 29 7:55 ./do-cm3-all.py realclean 30 7:55 ./do-cm3-std.py buildship 31 8:02 ./do-cm3-all.py buildship

30 is probably redundant.

Can you describe a bit more what you're doing? How old is your current build, what's the precise sequence of things you're doing?

Mika

On Thu, Mar 14, 2019 at 11:24 PM Harris Brakmić notifications@github.com wrote:

I'm trying to compile an AMD64_DARWIN release on my Mac but it always stops at this step:

new exporters -> recompiling HMTime.i3 -> archiving libcit_util.a Undefined symbols for architecture x86_64: "_UtimeOpsCdelete_T", referenced from: _UtimeWrapdelete_T in UtimeWrap_m.o "_UtimeOpsCmake_T", referenced from: _UtimeWrapmake_T in UtimeWrap_m.o "_UtimeOpsCcheck_types", referenced from: _UtimeOpsC_M3 in UtimeOpsC_m.o "_UtimeOpsCGet_second", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_minute", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_hour", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_month", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_year", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsC__mktime", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCGet_wday", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCSet_second", referenced from: _TZMktime in TZ_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCSet_day", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCGet_gmtoff", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCSet_month", referenced from: _TZMktime in TZ_m.o "_CTZsetTZ", referenced from: _TZSetCurTZ in TZ_m.o _TZ_M3 in TZ_m.o "_UtimeOpsCGet_zone", referenced from: _UCTimectime in UCTime_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCwrite_double_clock", referenced from: _UCTimectime in UCTime_m.o "_UtimeOpsCSet_year", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCSet_minute", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCctime_r", referenced from: _UCTimectime in UCTime_m.o "_UtimeOpsCGet_day", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsClocaltime_r", referenced from: _UCTimectime in UCTime_m.o _TZMktime in TZ_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCSet_hour", referenced from: _TZMktime in TZ_m.o "_diskAvail", referenced from: _SysPerfDiskAvail in SysPerf_m.o "_getloadavg_glue", referenced from: _SysPerfGetLoadAvg in SysPerf_m.o "_printf_prints", referenced from: _RTRefStats__Visit in RTRefStats_m.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make_lib => 1 librarian failed building: cit_util Fatal Error: package build failed execution of [<function _BuildGlobalFunction at 0x10f6b87d0>, <function _ShipFunction at 0x10f6b8848>] failed ERROR: ./do-cm3-all.py buildship

I've properly setup the environment, with the latest available x64 compiler release for macOS. I've used boot2.py from scripts/python directory to kickoff the compilation.

I'm not sure if there are any alternative ways to compile the toolchain.

Kind regards,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpa1G8xQ_uv2NXgwiqKWBvxUmS70-ks5vWtobgaJpZM4b1aCr .

brakmic commented 5 years ago
mikanystrom commented 5 years ago

Hmm can you try to do what I just did?

unpack the package as you did, add cm3 to your path, then

setenv CM3 which cm3

./do-cm3-all.py realclean ./do-cm3-all.py buildship

?

I don't have access to AMD64_DARWIN right now. Do you have access to AMD64_LINUX anywhere? I built on this:

Linux debian 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2018-10-08) x86_64 GNU/Linux

On Fri, Mar 15, 2019 at 8:15 AM Harris Brakmić notifications@github.com wrote:

  • I've used the latest available cm3 package for x64 macOS: cm3-bin-core-AMD64_DARWIN-d5.10.0-i386-unknown-Darwin15.6.0-2016-11-20-19-16-08.tgz

  • the CM3 sources are from the current master.

  • I installed the cm3 package to /usr/local/cm3

  • set the CM3_ROOT to point it

  • and then went to compile it with scripts/python/boot2.py.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473196520, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpUJ_ql4JVlap2r0tLbmn_PvOWvXkks5vW1apgaJpZM4b1aCr .

brakmic commented 5 years ago

Ok, I've started the compilation process again. Will come back when I know more. I only use macOS, so no AMD64_LINUX here.

mikanystrom commented 5 years ago

yeah it should work on either...

On Fri, Mar 15, 2019 at 9:10 AM Harris Brakmić notifications@github.com wrote:

Ok, I've started the compilation process again. Will come back when I know more. I only use macOS, so no AMD64_LINUX here.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473211141, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpX_u4GJsFO0L31wR9Czk9G0QqJSCks5vW2N2gaJpZM4b1aCr .

brakmic commented 5 years ago

I hope so :) And if it works I think I could make a package containing all the binaries/libs so other macOS users don't have to repeat it again.

Not sure how to contact the maintainers of this repo. 🤔

brakmic commented 5 years ago

Hm, same error. :(

brakmic commented 5 years ago
  "_getloadavg_glue", referenced from:
      _SysPerf__GetLoadAvg in SysPerf_m.o
  "_printf_prints", referenced from:
      _RTRefStats__Visit in RTRefStats_m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make_lib => 1
brakmic commented 5 years ago

However, I think this error has to do with certain flags passed to the linker on macOS. I had a similar error in some other package unrelated to cm3. When I checked the Makefile there it came out that my linker doesn't accept certain flags like -dyand -dn. After I have removed them the compilation could continue.

So maybe I am experiencing the same problem with cm3?

mikanystrom commented 5 years ago

I think you just did contact the "maintainers" of the repo!

Ahhhh I see what the issue is!

I think all your linking errors have to do with linking with C code. Can you use nm to figure out what symbols are actually being exported from the compilations of the C files?

There is other C code in the CM3 distribution, I'm sure (at least in m3core!)... I am not sure what we did differently in cit_util from those places.

Also cm3 -keep -verbose is really useful. If you sit in the derived directory (i.e., AMD64_DARWIN in your case) you can issue the commands from the command line and it should work the same as having cm3 do the work for you.

Something more extreme you could do is remove the Caltech code from your pkginfo.txt and rebuilding. If you do that, the build won't attempt them at all. You can start with removing cit_util itself and then cut out whatever dependencies there are. Then at least you will make some progress.

On Fri, Mar 15, 2019 at 9:19 AM Harris Brakmić notifications@github.com wrote:

However, I think this error has to do with certain flags passed to the linker on macOS. I had a similar error in some other package unrelated to cm3. When I checked the Makefile there it came out that my linker doesn't accept certain flags like -dyand -dn. After I have removed them the compilation could continue.

So maybe I am experiencing the same problem with cm3?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473213643, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpXIOwBC92Uc5lmVmNR1IPrbYfQ4Rks5vW2WGgaJpZM4b1aCr .

brakmic commented 5 years ago

Ok, then I will try all the methods and report back!

brakmic commented 5 years ago

Here is the output of nm libcit_common.dylib from cm3/caltech-parser/cit_common/AMD64_DARWIN

nm libcit_common.dylib
                 U _FloatMode_I3
00000000000040c0 s _L_1
0000000000004160 s _L_1
                 U _Lex_I3
0000000000004560 d _MI_TextReader
0000000000004720 d _MM_TextReader
                 U _RTHooks_I3
                 U _RTHooks__AllocateTracedObj
                 U _RTHooks__CheckLoadTracedRef
                 U _RTHooks__CheckStoreTraced
                 U _RTHooks__Concat
                 U _RTHooks__PopEFrame
                 U _RTHooks__PushEFrame
                 U _RTHooks__Raise
                 U _RTHooks__ReportFault
                 U _RTHooks__TextLitGetChar
                 U _RTHooks__TextLitGetChars
                 U _RTHooks__TextLitGetWideChar
                 U _RTHooks__TextLitGetWideChars
                 U _RTHooks__TextLitInfo
                 U _RdCopy_I3
                 U _RdCopy__ToWriter
                 U _Rd_I3
                 U _Scan_I3
                 U _Scan__Bool
                 U _Scan__Int
                 U _Scan__LongReal
                 U _TextList_I3
                 U _TextList__Cons
                 U _TextList__ReverseD
0000000000002173 T _TextReader_I3
000000000000392c T _TextReader_M3
00000000000024ba t _TextReader__Get
0000000000003811 t _TextReader__GetBool
0000000000003852 t _TextReader__GetCard
00000000000037ca t _TextReader__GetInt
0000000000003776 t _TextReader__GetLR
0000000000003138 t _TextReader__Init
00000000000031ea t _TextReader__InitFromRd
000000000000261a t _TextReader__IsEmpty
00000000000038e0 T _TextReader__New
0000000000002f78 t _TextReader__Next
0000000000002521 t _TextReader__NextE
000000000000269a t _TextReader__NextS
000000000000259d t _TextReader__NextSE
0000000000003614 t _TextReader__PushBack
0000000000002184 t _TextReader__Save
00000000000033d1 t _TextReader__Shatter
00000000000032e8 t _TextReader__Shatter__CheckOverlap.1166
0000000000002321 t _TextReader__Unwind
                 U _TextWr_I3
                 U _TextWr__ToText
                 U _Text_I3
                 U _Text__FindChar
                 U _Text__GetChar
                 U _Text__Length
                 U _Text__Sub
                 U _Thread_I3
                 U _Wr_I3
000000000000393d t __m3_fault
                 U __setjmp
                 U _m3_jmpbuf_size
                 U _set_union
                 U dyld_stub_binder
brakmic commented 5 years ago

When I execute cm3 -keep -verbose in cm3/caltech-parser I get this error (maybe completely unrelated to my problem, so not sure how helful this info is):

Looking in ../drawcontext/src
ignoring ../drawcontext/src/form.ps (not a directory)
ignoring ../drawcontext/src/m3makefile (not a directory)
ignoring ../drawcontext/src/m3overrides (not a directory)
ignoring ../drawcontext/src/times.afm (not a directory)
ignoring ../AMD64_DARWIN (derived object directory)
ignoring ../PkgTags (not a directory)
EVAL ("m3make.args")
rm .M3SHIP
rm .M3OVERRIDES
rm Main.o
ln -s ../m3tmplhack/AMD64_DARWIN/Main.o Main.o
rm _m3main.o
ln -s ../m3tmplhack/AMD64_DARWIN/_m3main.o _m3main.o

Fatal Error: duplicate unit: ../m3tmplhack/src/Main.m3 ../m3browserhack/src/Main.m3

 seconds  #times  operation
    0.02       3  garbage collection
    0.29          other
---------------------------------------------------
    0.31          TOTAL

cd ..
is_empty (AMD64_DARWIN) => Main.o
brakmic commented 5 years ago

And this is the result of cm3 -keep -verbose in cm3/caltech-parser/cit_util (showing only the last few lines)

  "_UtimeOpsC__Get_day", referenced from:
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__localtime_r", referenced from:
      _UCTime__ctime in UCTime_m.o
      _TZ__Mktime in TZ_m.o
      _TZ__Localtime in TZ_m.o
  "_UtimeOpsC__Set_hour", referenced from:
      _TZ__Mktime in TZ_m.o
  "_diskAvail", referenced from:
      _SysPerf__DiskAvail in SysPerf_m.o
  "_getloadavg_glue", referenced from:
      _SysPerf__GetLoadAvg in SysPerf_m.o
  "_printf_prints", referenced from:
      _RTRefStats__Visit in RTRefStats_m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rm libcit_util.a
  make_lib => 1
  make_lib => 1
librarian failed building: cit_util
Fatal Error: package build failed

 seconds  #times  operation
    0.03      10  inhaling library link info
    0.18       1  getting derived timestamps
    0.01     384  checking timestamps
    0.01     379  checking old link info
    0.02     363  merging new link info
    0.45       1  building library archive
    0.02       3  garbage collection
---------------------------------------------------
    0.75          TOTAL

cd ..
mikanystrom commented 5 years ago

OK, but there should be some .o files of some kind too. If we look at just one of your error messages:

"_CTZ__setTZ", referenced from: _TZ__SetCurTZ in TZ_m.o _TZ_M3 in TZ_m.o

There's a pair of files:

CTZ.c

CTZ.i3

CTZ.i3 describes what the Modula-3 importers expect to see. The symbols declared in CTZ.i3 are meant to be exported by CTZ.c .

For example the following C code

void CTZ__setTZ(const char *tzname) { int res = setenv("TZ",tzname,1); assert(res==0); tzset(); }

is meant to implement

<EXTERNAL CTZ__setTZ > PROCEDURE setTZ(name : const_char_star);

Now maybe it doesn't work right...

if I look at m3core.h (look for that file) they do complicated things that might solve the problem.... Hrmmm....

On Fri, Mar 15, 2019 at 9:42 AM Harris Brakmić notifications@github.com wrote:

Here is the output of nm libcit_common.dylib from cm3/caltech-parser/cit_common/AMD64_DARWIN

nm libcit_common.dylib U _FloatMode_I3 00000000000040c0 s _L_1 0000000000004160 s _L_1 U _Lex_I3 0000000000004560 d _MI_TextReader 0000000000004720 d _MM_TextReader U _RTHooks_I3 U _RTHooksAllocateTracedObj U _RTHooks__CheckLoadTracedRef U _RTHooksCheckStoreTraced U _RTHooksConcat U _RTHooks__PopEFrame U _RTHooksPushEFrame U _RTHooksRaise U _RTHooks__ReportFault U _RTHooksTextLitGetChar U _RTHooksTextLitGetChars U _RTHooks__TextLitGetWideChar U _RTHooksTextLitGetWideChars U _RTHooksTextLitInfo U _RdCopy_I3 U _RdCopy__ToWriter U _Rd_I3 U _Scan_I3 U _ScanBool U _ScanInt U _Scan__LongReal U _TextList_I3 U _TextListCons U _TextListReverseD 0000000000002173 T _TextReader_I3 000000000000392c T _TextReader_M3 00000000000024ba t _TextReader__Get 0000000000003811 t _TextReaderGetBool 0000000000003852 t _TextReaderGetCard 00000000000037ca t _TextReader__GetInt 0000000000003776 t _TextReaderGetLR 0000000000003138 t _TextReaderInit 00000000000031ea t _TextReader__InitFromRd 000000000000261a t _TextReaderIsEmpty 00000000000038e0 T _TextReaderNew 0000000000002f78 t _TextReader__Next 0000000000002521 t _TextReaderNextE 000000000000269a t _TextReaderNextS 000000000000259d t _TextReader__NextSE 0000000000003614 t _TextReaderPushBack 0000000000002184 t _TextReaderSave 00000000000033d1 t _TextReader__Shatter 00000000000032e8 t _TextReaderShatterCheckOverlap.1166 0000000000002321 t _TextReader__Unwind U _TextWr_I3 U _TextWrToText U _Text_I3 U _TextFindChar U _Text__GetChar U _TextLength U _TextSub U _Thread_I3 U _Wr_I3 000000000000393d t m3_fault U __setjmp U _m3_jmpbuf_size U _set_union U dyld_stub_binder

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473220876, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpdIFrIGnW8JLiyfpzNrCVMyVJg4Wks5vW2r9gaJpZM4b1aCr .

mikanystrom commented 5 years ago

yeah you can't run it in caltech-parser. Because there are multiple libraries or programs below that point in the source tree. You have to run cm3 in a directory containing precisely one program or library.

On Fri, Mar 15, 2019 at 9:45 AM Harris Brakmić notifications@github.com wrote:

When I execute cm3 -keep -verbose in cm3/caltech-parser I get this error (maybe completely unrelated to my problem, so not sure how helful this info is):

Looking in ../drawcontext/src ignoring ../drawcontext/src/form.ps (not a directory) ignoring ../drawcontext/src/m3makefile (not a directory) ignoring ../drawcontext/src/m3overrides (not a directory) ignoring ../drawcontext/src/times.afm (not a directory) ignoring ../AMD64_DARWIN (derived object directory) ignoring ../PkgTags (not a directory) EVAL ("m3make.args") rm .M3SHIP rm .M3OVERRIDES rm Main.o ln -s ../m3tmplhack/AMD64_DARWIN/Main.o Main.o rm _m3main.o ln -s ../m3tmplhack/AMD64_DARWIN/_m3main.o _m3main.o

Fatal Error: duplicate unit: ../m3tmplhack/src/Main.m3 ../m3browserhack/src/Main.m3

seconds #times operation 0.02 3 garbage collection 0.29 other

0.31          TOTAL

cd .. is_empty (AMD64_DARWIN) => Main.o

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473221810, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpRwBiOQAbXoOC0-VNybWXhfn6ebMks5vW2u1gaJpZM4b1aCr .

brakmic commented 5 years ago

Ok, didn't know that. So I will run it in cm3 itself. Btw. here the nm output for TZ_m.o

0000000000001478 s EH_frame1
                 U _CTZ_I3
                 U _CTZ__setTZ
                 U _Ctypes_I3
                 U _Date_I3
                 U _Debug_I3
                 U _Debug__GetLevel
                 U _Debug__Out
                 U _Env_I3
                 U _Env__Get
                 U _FS_I3
                 U _FS__Status
                 U _Fmt_I3
                 U _Fmt__LongReal
0000000000000de0 s _L_1
                 U _M3toC_I3
                 U _M3toC__CopyStoT
                 U _M3toC__CopyTtoS
                 U _M3toC__FreeCopiedS
0000000000001180 d _MM_TZ
                 U _OSError_I3
                 U _RTHooks_I3
                 U _RTHooks__AllocateTracedObj
                 U _RTHooks__CheckLoadTracedRef
                 U _RTHooks__CheckStoreTraced
                 U _RTHooks__Concat
                 U _RTHooks__PopEFrame
                 U _RTHooks__PushEFrame
                 U _RTHooks__ReportFault
                 U _RTHooks__TextLitGetChar
                 U _RTHooks__TextLitGetChars
                 U _RTHooks__TextLitGetWideChar
                 U _RTHooks__TextLitGetWideChars
                 U _RTHooks__TextLitInfo
                 U _SchedulerIndirection_I3
                 U _SchedulerIndirection__DisableSwitching
                 U _SchedulerIndirection__EnableSwitching
                 U _TZ_I3
0000000000000460 T _TZ_M3
0000000000000340 t _TZ_M3_LINE_170.1170
0000000000000000 t _TZ_M3_LINE_178.1172
0000000000000010 t _TZ_M3_LINE_206.1174
0000000000000020 t _TZ_M3_LINE_82.1168
0000000000000530 t _TZ_M3_t099ad545_INIT
0000000000000450 T _TZ__DisableChecking
0000000000000050 T _TZ__Equal
0000000000000360 t _TZ__GetOldTZ
0000000000000160 T _TZ__Hash
00000000000001a0 t _TZ__Init
0000000000000730 t _TZ__Localtime
0000000000000550 t _TZ__Mktime
0000000000000170 t _TZ__Name
00000000000002b0 t _TZ__SetCurTZ
                 U _Text_I3
                 U _Text__Equal
                 U _Text__GetChar
                 U _Text__Hash
                 U _Text__Sub
                 U _Thread_I3
                 U _Thread__Acquire
                 U _Thread__Release
                 U _UtimeOpsC_I3
                 U _UtimeOpsC__Get_day
                 U _UtimeOpsC__Get_gmtoff
                 U _UtimeOpsC__Get_hour
                 U _UtimeOpsC__Get_minute
                 U _UtimeOpsC__Get_month
                 U _UtimeOpsC__Get_second
                 U _UtimeOpsC__Get_wday
                 U _UtimeOpsC__Get_year
                 U _UtimeOpsC__Get_zone
                 U _UtimeOpsC__Set_day
                 U _UtimeOpsC__Set_hour
                 U _UtimeOpsC__Set_minute
                 U _UtimeOpsC__Set_month
                 U _UtimeOpsC__Set_second
                 U _UtimeOpsC__Set_year
                 U _UtimeOpsC__localtime_r
                 U _UtimeOpsC__mktime
                 U _UtimeWrap_I3
                 U _UtimeWrap__delete_T
                 U _UtimeWrap__make_T
                 U _Word_I3
                 U _XTime_I3
                 U _XTime__Now
0000000000000540 t __m3_fault
                 U _getenv
brakmic commented 5 years ago

Now got this error. Not sure if I am doing something wrong.

gnoring ../m3-tools/m3totex/src/m3overrides (not a directory)
ignoring ../m3-tools/m3totex/src/Example.tex (not a directory)
ignoring ../m3-tools/m3totex/src/COPYRIGHT (not a directory)
ignoring ../m3-tools/m3totex/src/m3totex.1 (not a directory)
EVAL ("m3make.args")
rm .M3SHIP
rm .M3OVERRIDES

Fatal Error: duplicate unit: ../m3-games/fours/src/Main.m3 ../m3-games/tetris/src/Main.m3

 seconds  #times  operation
    1.08      74  garbage collection
    3.70          other
---------------------------------------------------
    4.78          TOTAL

cd ..
mikanystrom commented 5 years ago

no, you have to run cm3 where there is ONE thing you are building.

cm3 contains dozens if not hundreds of things to build.

cit_util is one library, so you can run cm3 there. You can't run it higher up in the directory tree.

On Fri, Mar 15, 2019 at 9:53 AM Harris Brakmić notifications@github.com wrote:

Now got this error. Not sure if I am doing something wrong.

gnoring ../m3-tools/m3totex/src/m3overrides (not a directory) ignoring ../m3-tools/m3totex/src/Example.tex (not a directory) ignoring ../m3-tools/m3totex/src/COPYRIGHT (not a directory) ignoring ../m3-tools/m3totex/src/m3totex.1 (not a directory) EVAL ("m3make.args") rm .M3SHIP rm .M3OVERRIDES

Fatal Error: duplicate unit: ../m3-games/fours/src/Main.m3 ../m3-games/tetris/src/Main.m3

seconds #times operation 1.08 74 garbage collection 3.70 other

4.78          TOTAL

cd ..

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473224278, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpQi1J47dW6vLCMe8-ipZ9ykO-Q2jks5vW22EgaJpZM4b1aCr .

mikanystrom commented 5 years ago

yeah so continuing my example...

             U _CTZ__setTZ

that means that the symbol _CTZ__setTZ is Undefined in TZ, it's trying to import it from somewhere (we know it should be defined in CTZ, not TZ---btw the "C" in CTZ suggests that file is coded in C, not Modula-3).

Is there a file called CTZ.o or anything like that? that is the file that should be exporting the symbol. It's being imported into TZ...

On Fri, Mar 15, 2019 at 9:51 AM Harris Brakmić notifications@github.com wrote:

Ok, didn't know that. So I will run it in cm3 itself. Btw. here the nm output for TZ_m.o

0000000000001478 s EH_frame1 U _CTZ_I3 U _CTZsetTZ U _Ctypes_I3 U _Date_I3 U _Debug_I3 U _Debug__GetLevel U _DebugOut U _Env_I3 U _EnvGet U _FS_I3 U _FS__Status U _Fmt_I3 U _FmtLongReal 0000000000000de0 s _L_1 U _M3toC_I3 U _M3toCCopyStoT U _M3toC__CopyTtoS U _M3toCFreeCopiedS 0000000000001180 d _MM_TZ U _OSError_I3 U _RTHooks_I3 U _RTHooksAllocateTracedObj U _RTHooks__CheckLoadTracedRef U _RTHooksCheckStoreTraced U _RTHooksConcat U _RTHooks__PopEFrame U _RTHooksPushEFrame U _RTHooksReportFault U _RTHooks__TextLitGetChar U _RTHooksTextLitGetChars U _RTHooksTextLitGetWideChar U _RTHooks__TextLitGetWideChars U _RTHooksTextLitInfo U _SchedulerIndirection_I3 U _SchedulerIndirectionDisableSwitching U _SchedulerIndirection__EnableSwitching U _TZ_I3 0000000000000460 T _TZ_M3 0000000000000340 t _TZ_M3_LINE_170.1170 0000000000000000 t _TZ_M3_LINE_178.1172 0000000000000010 t _TZ_M3_LINE_206.1174 0000000000000020 t _TZ_M3_LINE_82.1168 0000000000000530 t _TZ_M3_t099ad545_INIT 0000000000000450 T _TZDisableChecking 0000000000000050 T _TZEqual 0000000000000360 t _TZ__GetOldTZ 0000000000000160 T _TZHash 00000000000001a0 t _TZInit 0000000000000730 t _TZ__Localtime 0000000000000550 t _TZMktime 0000000000000170 t _TZName 00000000000002b0 t _TZ__SetCurTZ U _Text_I3 U _TextEqual U _TextGetChar U _Text__Hash U _TextSub U _Thread_I3 U _ThreadAcquire U _Thread__Release U _UtimeOpsC_I3 U _UtimeOpsCGet_day U _UtimeOpsCGet_gmtoff U _UtimeOpsCGet_hour U _UtimeOpsCGet_minute U _UtimeOpsCGet_month U _UtimeOpsCGet_second U _UtimeOpsCGet_wday U _UtimeOpsCGet_year U _UtimeOpsCGet_zone U _UtimeOpsCSet_day U _UtimeOpsCSet_hour U _UtimeOpsCSet_minute U _UtimeOpsCSet_month U _UtimeOpsCSet_second U _UtimeOpsCSet_year U _UtimeOpsClocaltime_r U _UtimeOpsCmktime U _UtimeWrap_I3 U _UtimeWrapdelete_T U _UtimeWrapmake_T U _Word_I3 U _XTime_I3 U _XTimeNow 0000000000000540 t m3_fault U _getenv

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473223825, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpW6JH0reJX4Qxfa14d5ktQKEb5ROks5vW20vgaJpZM4b1aCr .

brakmic commented 5 years ago

Ok, I understand. Will now search for CTZ<anything>.o file.

no, you have to run cm3 where there is ONE thing you are building. cm3 contains dozens if not hundreds of things to build. cit_util is one library, so you can run cm3 there. You can't run it higher up in the directory tree. On Fri, Mar 15, 2019 at 9:53 AM Harris Brakmić @.***> wrote: Now got this error. Not sure if I am doing something wrong. gnoring ../m3-tools/m3totex/src/m3overrides (not a directory) ignoring ../m3-tools/m3totex/src/Example.tex (not a directory) ignoring ../m3-tools/m3totex/src/COPYRIGHT (not a directory) ignoring ../m3-tools/m3totex/src/m3totex.1 (not a directory) EVAL ("m3make.args") rm .M3SHIP rm .M3OVERRIDES Fatal Error: duplicate unit: ../m3-games/fours/src/Main.m3 ../m3-games/tetris/src/Main.m3 seconds #times operation 1.08 74 garbage collection 3.70 other --------------------------------------------------- 4.78 TOTAL cd .. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#46 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpQi1J47dW6vLCMe8-ipZ9ykO-Q2jks5vW22EgaJpZM4b1aCr .

brakmic commented 5 years ago

Here are two of them:

CTZ_i.oand CTZ.o

I assume object files for implementations and interfaces?

Here the results of nm for each one:


$ nm CTZ.o
0000000000000070 T __Z10CTZ__setTZPKc
0000000000000000 T __Z31CTZ__setenv_TZ_America_New_Yorkv
                 U ___assert_rtn
                 U _setenv
                 U _tzset

$ nm CTZ_i.o
00000000000000f0 s EH_frame1
0000000000000000 T _CTZ_I3
                 U _Ctypes_I3
00000000000000c0 s _L_1
0000000000000020 d _MI_CTZ
                 U _RTHooks_I3
brakmic commented 5 years ago

One speculation:

As Apple is no longer supporting x86 architecture, and I have the latest XCode + toolchain installed, maybe it's because your C compiler only generates x86 binaries?

brakmic commented 5 years ago

However, both of the object files are for x64, so my assumption is wrong.

CTZ_i.o: Mach-O 64-bit object x86_64
brakmic commented 5 years ago

After having removed the caltech_ files as you recommended I was able to successfully compile the distribution. Many thanks for your help! 👍

cm3 --version
Critical Mass Modula-3 version d5.10.0
  last updated: 2016-10-05
  compiled: 2019-03-15 11:40:07
  configuration: /usr/local/cm3/bin/cm3.cfg
  host: AMD64_DARWIN
  target: AMD64_DARWIN

Here's the patch file and tarballs for other macOS x64 users to save their time. :)

Downloads are located on my server. Fingerprints and malware reports are from virustotal.com.

EDIT: scroll down for updated links!

Best regards,

mikanystrom commented 5 years ago

yep you're right, CTZ.o is from the C file, CTZ_i.o is from the i3 file.

You can see what the problem is here. The C compiler has mangled the name from CTZsetTZ to Z10CTZ__setTZPKc.

Can you tell me what the C compiler command that generated the CTZ.o is? It should be visible in the output when you run cm3 in that directory.

I have a suspicion.

I would guess.... maybe... that the problem is that you're using a C++ compiler to compile a C file without adding some extra magic to tell the C++ compiler that you're compiling C code. C++ compilers like to mangle symbol names in various ways.

I think the history here is that a while back, someone checked in the CM3 distribution configured so that compiling C files ("c_source" in the m3makefile) would happen with the C++ compiler. This seemed necessary because we use the C++ for final linking.

But I think that it's not really necessary to use a C++ compiler to compile C code. Using the C++ compiler to compile C code has the benefit that C code and C++ code is compiled the same way, but I am not sure there's any benefit beyond that (and some issues as you can see).

If you look in the m3config files for AMD64_LINUX you can see that I undid the decision to use the C++ compiler to compile C code. I am thinking we need to do something similar for AMD64_DARWIN.

I would love to see this fixed, but as I said, I don't really have access to AMD64_DARWIN at the moment myself.

Mika

On Fri, Mar 15, 2019 at 10:02 AM Harris Brakmić notifications@github.com wrote:

Here are two of them:

CTZ_i.oand CTZ.o

I assume object files for implementations and interfaces?

Here the results of nm for each one:

$ nm CTZ.o 0000000000000070 T Z10CTZsetTZPKc 0000000000000000 T Z31CTZsetenv_TZ_America_New_Yorkv U ___assert_rtn U _setenv U _tzset

$ nm CTZ_i.o 00000000000000f0 s EH_frame1 0000000000000000 T _CTZ_I3 U _Ctypes_I3 00000000000000c0 s _L_1 0000000000000020 d _MI_CTZ U _RTHooks_I3

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473227182, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpZ5autn6HDTLAHzSRnWxjfRpfw0Iks5vW2-vgaJpZM4b1aCr .

brakmic commented 5 years ago

The compilation is being done with g++ but there is actually no g++ under macOS. It's always clang even if you type g++ or gcc, because Apple wants it so.

This is the compilation call in cit_util.

g++ -g -fPIC -Wall -Werror -Wno-return-type -Wno-missing-braces -m64 -arch x86_64 -dynamiclib -multiply_defined error -twolevel_namespace -compatibility_version 5 -current_version 5.2 -install_name @executable_path/../lib/libcit_util.5.dylib -headerpad_max_install_names -o libcit_util.5.2.dylib -dead_strip DblRefany_i.o Debug_i.o Debug_m.o DebugStream_i.o DebugStreamList_i.o DebugStreamList_m.o DebugClass_i.o DebugClass_m.o DebugFmtPointer_m.o BreakHere_i.o BreakHere_m.o TextUtils_i.o TextUtils_m.o WordUtils_i.o WordUtils_m.o TextUtilsFmt_m.o PrefixDB_i.o PrefixDB_m.o TextLongRealTbl_i.o TextLongRealTbl_m.o 

LongrealList_i.o LongrealList_m.o LongrealPQ_i.o LongrealPQRep_i.o LongrealPQ_m.o ScanList_i.o ScanList_m.o LockedTextRefTbl_i.o LockedTextRefTbl_m.o LockedTextSetDef_i.o LockedTextSetDef_m.o LockedTextBooleanTbl_i.o LockedTextBooleanTbl_m.o RTBrand_i.o RefRecord_i.o SchedulerIndirection_i.o RTBrandCM3_m.o RefRecordCM3_m.o SchedulerIndirectionCM3_m.o printf.o Cprintf_i.o RTRefStats_i.o RTRefStats_m.o RTName_i.o RTName_m.o SIsuffix_i.o SIsuffix_m.o SuffixTbl_i.o SuffixTbl_m.o IntPair_i.o IntPair_m.o RefPair_i.o RefPair_m.o TextCardPair_i.o TextCardPair_m.o TextIntPair_i.o TextIntPair_m.o TextIntPairRefTbl_i.o TextIntPairRefTbl_m.o RefPairSeq_i.o RefPairSeqRep_i.o RefPairSeq_m.o IntPairSeq_i.o IntPairSeqRep_i.o IntPairSeq_m.o IntPairList_i.o IntPairList_m.o IntTriple_i.o Int_IntTripleTbl_i.o Int_IntTripleTbl_m.o CardPair_i.o CardPair_m.o CardPairSet_i.o CardPairSet_m.o CardPairSetDef_i.o CardPairSetDef_m.o CardPairRefTbl_i.o CardPairRefTbl_m.o CardCardTbl_i.o CardCardTbl_m.o CardPairList_i.o CardPairList_m.o TextPair_i.o TextPair_m.o LongRealPair_i.o LongRealPair_m.o 

TextPairList_i.o TextPairList_m.o CardList_i.o CardList_m.o CardSet_i.o CardSet_m.o CardSetDef_i.o CardSetDef_m.o CardSetArray_i.o CardSetArray_m.o CardRefTbl_i.o CardRefTbl_m.o LongrealSet_i.o LongrealSet_m.o LongrealSetDef_i.o LongrealSetDef_m.o IntArrayRef_i.o IntArrayRef_m.o ToRefany_i.o ToRefany_m.o ToRefanyClass_i.o ToRefanyTbl_i.o ToRefanyTbl_m.o IntRef_i.o IntRef_m.o IntRefToRefany_i.o IntRefToRefany_m.o BoolRef_i.o BoolRef_m.o BoolRefToRefany_i.o BoolRefToRefany_m.o CharRef_i.o CharRef_m.o CharRefToRefany_i.o CharRefToRefany_m.o 

RealRef_i.o RealRef_m.o RealRefToRefany_i.o RealRefToRefany_m.o IntPairSet_i.o IntPairSet_m.o IntPairSetDef_i.o IntPairSetDef_m.o IntPairRefTbl_i.o IntPairRefTbl_m.o TextSubs_i.o TextSubs_m.o TextTextListTbl_i.o TextTextListTbl_m.o TextEquivalence_i.o TextEquivalence_m.o TextTextTblExtras_i.o TextTextTblExtras_m.o TextTextListTblExtras_i.o TextTextListTblExtras_m.o FewerDotsTextPref_i.o FewerDotsTextPref_m.o TextBooleanTbl_i.o TextBooleanTbl_m.o MapError_i.o LRVector_i.o LRVector_m.o LRPoint_i.o LRPt_i.o LRPt_m.o LRInterval_i.o LRInterval_m.o LongRealRef_i.o LongRealRef_m.o LongRealRefList_i.o LongRealRefList_m.o TextLongRealRefTbl_i.o TextLongRealRefTbl_m.o Threadd_i.o ThreadSeq_i.o ThreadSeqRep_i.o ThreadSeq_m.o MyLongrealType_i.o MyLongrealType_m.o LRFunction_i.o LRFunction_m.o LRScalarField_i.o LRScalarField_m.o LRVectorField_i.o LRVectorField_m.o LRParametricCurve_i.o 

LRParametricCurve_m.o Pointe_i.o Pointe_m.o BoolF_i.o TextFF_i.o TextFF_m.o TextListF_i.o TextListF_m.o BrandedRd_i.o RdList_i.o RdList_m.o CharF_i.o RefanyF_i.o RefanyF_m.o CharList_i.o CharList_m.o BoolList_i.o BoolList_m.o Cardinal_i.o Cardinal_m.o CardSeq_i.o CardSeqRep_i.o CardSeq_m.o CharSeq_i.o CharSeqRep_i.o CharSeq_m.o IntForRat_i.o IntForRat_m.o BigInt_i.o BigInt_m.o IntRational_i.o IntRational_m.o BigRational_i.o BigRational_m.o TextBigIntTbl_i.o TextBigIntTbl_m.o LilIntOps_i.o LilIntOps_m.o BigIntOps_i.o BigIntOps_m.o UnsafeMutex_i.o UnsafeMutex_m.o CatRd_i.o CatRd_m.o FileReWr_i.o FileReWr_m.o ObjectFactory_i.o ObjectFactory_m.o ObjectFactoryClass_i.o IntArrayHash_i.o IntArrayHash_m.o CITRandom_i.o CITRandom_m.o ProcUtils_i.o ProcUtils_m.o RemoteFileRd_i.o RemoteFileRd_m.o PathnameUtils_i.o PathnameUtils_m.o Config_i.o Config_m.o FlagList_i.o FlagList_m.o UnixUtils_i.o UnixUtils_m.o Stuff_i.o Stuff_m.o StuffSet_i.o StuffSet_m.o StuffSetDef_i.o StuffSetDef_m.o StuffRefTbl_i.o StuffRefTbl_m.o FmtScanVar_i.o FmtScanVar_m.o PMPTimer_i.o PMPTimer_m.o PointList_i.o 

PointList_m.o IntIntCache_i.o IntIntCache_m.o IDGen_i.o IDGen_m.o IDTextTbl_i.o IDTextTbl_m.o IDTextQueueTbl_i.o IDTextQueueTbl_m.o KeyObject_i.o KeyObject_m.o KeyObjectRefTbl_i.o KeyObjectRefTbl_m.o TextSetUtils_i.o TextSetUtils_m.o TextTextListMultiTblListMultiTbl_i.o TextTextListMultiTblListMultiTbl_m.o BrandedWr_i.o UnixFilter_i.o UnixFilter_m.o SlowTextCompress_i.o SlowTextCompress_m.o TextFifo_i.o TextFifo_m.o RefFifo_i.o RefFifo_m.o CharFifo_i.o CharFifo_m.o IntFifo_i.o IntFifo_m.o LongRealFifo_i.o LongRealFifo_m.o LongrealArraySort_i.o LongrealArraySort_m.o RefanyArraySort_i.o RefanyArraySort_m.o CardArraySort_i.o CardArraySort_m.o LongRealSeq_i.o LongRealSeqRep_i.o LongRealSeq_m.o LongrealSort_i.o LongrealSort_m.o Chmod_i.o Chmod_m.o LongRealSharedSeq_i.o LongRealSharedSeq_m.o LRArrayOps_i.o LRArrayOps_m.o PersistentIntRefTbl_i.o PersistentIntRefTbl_m.o FileSharing_i.o FileSharingPOSIX_m.o SysPerf_m.o c_SysPerf_i.o getloadavg_glue.o diskAvail.o SysPerf_i.o FileUtils_i.o FileUtils_m.o IntInt_i.o IntInt_m.o IntIntArraySort_i.o IntIntArraySort_m.o AL_i.o AL_m.o LineMatcher_i.o LineMatcher_m.o StepFunction_i.o StepFunction_m.o TCPMaker_i.o TCPMaker_m.o LimitFmt_i.o LimitFmt_m.o FancyFmt_i.o FancyFmt_m.o AttrWr_i.o AttrWr_m.o AttrWrSeq_i.o AttrWrSeqRep_i.o AttrWrSeq_m.o UCTime_i.o UCTime_m.o IntSetBits_i.o IntSetBits_m.o Hashable_i.o Hashable_m.o HashRefTbl_i.o 

HashRefTbl_m.o HashTextTbl_i.o HashTextTbl_m.o HashIntTbl_i.o HashIntTbl_m.o HashSet_i.o HashSet_m.o HashSetDef_i.o HashSetDef_m.o CTZ_i.o CTZ.o TZ_i.o TZ_m.o SafeTZ_m.o FinDate_i.o FinDate_m.o HMTime_i.o HMTime_m.o HMTimeToday_m.o IntFinDateTbl_i.o IntFinDateTbl_m.o FinDateArraySort_i.o FinDateArraySort_m.o AscTimeParse_i.o AscTimeParse_m.o TZRefTbl_i.o TZRefTbl_m.o LongrealRefTbl_i.o LongrealRefTbl_m.o SortedLongrealRefTbl_i.o SortedLongrealRefTbl_m.o SloppyTimeConverter_i.o SloppyTimeConverter_m.o XTime_i.o XTime_m.o LRElem_i.o LRElem_m.o LRElemArraySort_i.o LRElemArraySort_m.o UtimeOpsC_i.o UtimeOpsC_m.o UtimeWrap_i.o UtimeWrap_m.o UtimeOpsC.o FastNumParse_i.o FastNumParse_m.o -L/usr/local/cm3/pkg/patternmatching/AMD64_DARWIN -lpatternmatching -L/usr/local/cm3/pkg/libbuf/AMD64_DARWIN -llibbuf -L/usr/local/cm3/pkg/rdwr/AMD64_DARWIN -lrdwr -L/usr/local/cm3/pkg/set/AMD64_DARWIN -lset -L/usr/local/cm3/pkg/cit_common/AMD64_DARWIN -lcit_common -L/usr/local/cm3/pkg/netobj/AMD64_DARWIN -lm3netobj -L/usr/local/cm3/pkg/tcp/AMD64_DARWIN -lm3tcp -L/usr/local/cm3/pkg/libm3/AMD64_DARWIN -lm3 -L/usr/local/cm3/pkg/m3core/AMD64_DARWIN -lm3core -lSystem
Undefined symbols for architecture x86_64:

My clang is:

clang version 7.0.1 (tags/RELEASE_701/final)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
mikanystrom commented 5 years ago

hmmm well you don't think that clang behaves differently from being called as g++ vs gcc?

BTW that's not the command I was asking about. What you are showing is the linking command, not the compiling command of interest.

The one that's going wrong is some compilation command that compiles CTZ.c into CTZ.o ...

On Fri, Mar 15, 2019 at 2:23 PM Harris Brakmić notifications@github.com wrote:

The compilation is being done with g++ but there is actually no g++ under macOS. It'w always clang even if you type g++ or gcc, because Apple wants it so.

This is the compilation call in cit_util.

g++ -g -fPIC -Wall -Werror -Wno-return-type -Wno-missing-braces -m64 -arch x86_64 -dynamiclib -multiply_defined error -twolevel_namespace -compatibility_version 5 -current_version 5.2 -install_name @executable_path/../lib/libcit_util.5.dylib -headerpad_max_install_names -o libcit_util.5.2.dylib -dead_strip DblRefany_i.o Debug_i.o Debug_m.o DebugStream_i.o DebugStreamList_i.o DebugStreamList_m.o DebugClass_i.o DebugClass_m.o DebugFmtPointer_m.o BreakHere_i.o BreakHere_m.o TextUtils_i.o TextUtils_m.o WordUtils_i.o WordUtils_m.o TextUtilsFmt_m.o PrefixDB_i.o PrefixDB_m.o TextLongRealTbl_i.o TextLongRealTbl_m.o LongrealList_i.o LongrealList_m.o LongrealPQ_i.o LongrealPQRep_i.o LongrealPQ_m.o ScanList_i.o ScanList_m.o LockedTextRefTbl_i.o LockedTextRefTbl_m.o LockedTextSetDef_i.o LockedTextSetDef_m.o LockedTextBooleanTbl_i.o LockedTextBooleanTbl_m.o RTBrand_i.o RefRecord_i.o SchedulerIndirection_i.o RTBrandCM3_m.o RefRecordCM3_m.o SchedulerIndirectionCM3_m.o printf.o Cprintf_i.o RTRefStats_i.o RTRefStats_m.o RTName_i.o RTName_m.o SIsuffix_i.o SIsuffix_m.o SuffixTbl_i.o SuffixTbl_m.o IntPair_i.o IntPair_m.o RefPair_i.o RefPair_m.o TextCardPair_i.o TextCardPair_m.o TextIntPair_i.o TextIntPair_m.o TextIntPairRefTbl_i.o TextIntPairRefTbl_m.o RefPairSeq_i.o RefPairSeqRep_i.o RefPairSeq_m.o IntPairSeq_i.o IntPairSeqRep_i.o IntPairSeq_m.o IntPairList_i.o IntPairList_m.o IntTriple_i.o Int_IntTripleTbl_i.o Int_IntTripleTbl_m.o CardPair_i.o CardPair_m.o CardPairSet_i.o CardPairSet_m.o CardPairSetDef_i.o CardPairSetDef_m.o CardPairRefTbl_i.o CardPairRefTbl_m.o CardCardTbl_i.o CardCardTbl_m.o CardPairList_i.o CardPairList_m.o TextPair_i.o TextPair_m.o LongRealPair_i.o LongRealPair_m.o TextPairList_i.o TextPairList_m.o CardList_i.o CardList_m.o CardSet_i.o CardSet_m.o CardSetDef_i.o CardSetDef_m.o CardSetArray_i.o CardSetArray_m.o CardRefTbl_i.o CardRefTbl_m.o LongrealSet_i.o LongrealSet_m.o LongrealSetDef_i.o LongrealSetDef_m.o IntArrayRef_i.o IntArrayRef_m.o ToRefany_i.o ToRefany_m.o ToRefanyClass_i.o ToRefanyTbl_i.o ToRefanyTbl_m.o IntRef_i.o IntRef_m.o IntRefToRefany_i.o IntRefToRefany_m.o BoolRef_i.o BoolRef_m.o BoolRefToRefany_i.o BoolRefToRefany_m.o CharRef_i.o CharRef_m.o CharRefToRefany_i.o CharRefToRefany_m.o RealRef_i.o RealRef_m.o RealRefToRefany_i.o RealRefToRefany_m.o IntPairSet_i.o IntPairSet_m.o IntPairSetDef_i.o IntPairSetDef_m.o IntPairRefTbl_i.o IntPairRefTbl_m.o TextSubs_i.o TextSubs_m.o TextTextListTbl_i.o TextTextListTbl_m.o TextEquivalence_i.o TextEquivalence_m.o TextTextTblExtras_i.o TextTextTblExtras_m.o TextTextListTblExtras_i.o TextTextListTblExtras_m.o FewerDotsTextPref_i.o FewerDotsTextPref_m.o TextBooleanTbl_i.o TextBooleanTbl_m.o MapError_i.o LRVector_i.o LRVector_m.o LRPoint_i.o LRPt_i.o LRPt_m.o LRInterval_i.o LRInterval_m.o LongRealRef_i.o LongRealRef_m.o LongRealRefList_i.o LongRealRefList_m.o TextLongRealRefTbl_i.o TextLongRealRefTbl_m.o Threadd_i.o ThreadSeq_i.o ThreadSeqRep_i.o ThreadSeq_m.o MyLongrealType_i.o MyLongrealType_m.o LRFunction_i.o LRFunction_m.o LRScalarField_i.o LRScalarField_m.o LRVectorField_i.o LRVectorField_m.o LRParametricCurve_i.o LRParametricCurve_m.o Pointe_i.o Pointe_m.o BoolF_i.o TextFF_i.o TextFF_m.o TextListF_i.o TextListF_m.o BrandedRd_i.o RdList_i.o RdList_m.o CharF_i.o RefanyF_i.o RefanyF_m.o CharList_i.o CharList_m.o BoolList_i.o BoolList_m.o Cardinal_i.o Cardinal_m.o CardSeq_i.o CardSeqRep_i.o CardSeq_m.o CharSeq_i.o CharSeqRep_i.o CharSeq_m.o IntForRat_i.o IntForRat_m.o BigInt_i.o BigInt_m.o IntRational_i.o IntRational_m.o BigRational_i.o BigRational_m.o TextBigIntTbl_i.o TextBigIntTbl_m.o LilIntOps_i.o LilIntOps_m.o BigIntOps_i.o BigIntOps_m.o UnsafeMutex_i.o UnsafeMutex_m.o CatRd_i.o CatRd_m.o FileReWr_i.o FileReWr_m.o ObjectFactory_i.o ObjectFactory_m.o ObjectFactoryClass_i.o IntArrayHash_i.o IntArrayHash_m.o CITRandom_i.o CITRandom_m.o ProcUtils_i.o ProcUtils_m.o RemoteFileRd_i.o RemoteFileRd_m.o PathnameUtils_i.o PathnameUtils_m.o Config_i.o Config_m.o FlagList_i.o FlagList_m.o UnixUtils_i.o UnixUtils_m.o Stuff_i.o Stuff_m.o StuffSet_i.o StuffSet_m.o StuffSetDef_i.o StuffSetDef_m.o StuffRefTbl_i.o StuffRefTbl_m.o FmtScanVar_i.o FmtScanVar_m.o PMPTimer_i.o PMPTimer_m.o PointList_i.o PointList_m.o IntIntCache_i.o IntIntCache_m.o IDGen_i.o IDGen_m.o IDTextTbl_i.o IDTextTbl_m.o IDTextQueueTbl_i.o IDTextQueueTbl_m.o KeyObject_i.o KeyObject_m.o KeyObjectRefTbl_i.o KeyObjectRefTbl_m.o TextSetUtils_i.o TextSetUtils_m.o TextTextListMultiTblListMultiTbl_i.o TextTextListMultiTblListMultiTbl_m.o BrandedWr_i.o UnixFilter_i.o UnixFilter_m.o SlowTextCompress_i.o SlowTextCompress_m.o TextFifo_i.o TextFifo_m.o RefFifo_i.o RefFifo_m.o CharFifo_i.o CharFifo_m.o IntFifo_i.o IntFifo_m.o LongRealFifo_i.o LongRealFifo_m.o LongrealArraySort_i.o LongrealArraySort_m.o RefanyArraySort_i.o RefanyArraySort_m.o CardArraySort_i.o CardArraySort_m.o LongRealSeq_i.o LongRealSeqRep_i.o LongRealSeq_m.o LongrealSort_i.o LongrealSort_m.o Chmod_i.o Chmod_m.o LongRealSharedSeq_i.o LongRealSharedSeq_m.o LRArrayOps_i.o LRArrayOps_m.o PersistentIntRefTbl_i.o PersistentIntRefTbl_m.o FileSharing_i.o FileSharingPOSIX_m.o SysPerf_m.o c_SysPerf_i.o getloadavg_glue.o diskAvail.o SysPerf_i.o FileUtils_i.o FileUtils_m.o IntInt_i.o IntInt_m.o IntIntArraySort_i.o IntIntArraySort_m.o AL_i.o AL_m.o LineMatcher_i.o LineMatcher_m.o StepFunction_i.o StepFunction_m.o TCPMaker_i.o TCPMaker_m.o LimitFmt_i.o LimitFmt_m.o FancyFmt_i.o FancyFmt_m.o AttrWr_i.o AttrWr_m.o AttrWrSeq_i.o AttrWrSeqRep_i.o AttrWrSeq_m.o UCTime_i.o UCTime_m.o IntSetBits_i.o IntSetBits_m.o Hashable_i.o Hashable_m.o HashRefTbl_i.o HashRefTbl_m.o HashTextTbl_i.o HashTextTbl_m.o HashIntTbl_i.o HashIntTbl_m.o HashSet_i.o HashSet_m.o HashSetDef_i.o HashSetDef_m.o CTZ_i.o CTZ.o TZ_i.o TZ_m.o SafeTZ_m.o FinDate_i.o FinDate_m.o HMTime_i.o HMTime_m.o HMTimeToday_m.o IntFinDateTbl_i.o IntFinDateTbl_m.o FinDateArraySort_i.o FinDateArraySort_m.o AscTimeParse_i.o AscTimeParse_m.o TZRefTbl_i.o TZRefTbl_m.o LongrealRefTbl_i.o LongrealRefTbl_m.o SortedLongrealRefTbl_i.o SortedLongrealRefTbl_m.o SloppyTimeConverter_i.o SloppyTimeConverter_m.o XTime_i.o XTime_m.o LRElem_i.o LRElem_m.o LRElemArraySort_i.o LRElemArraySort_m.o UtimeOpsC_i.o UtimeOpsC_m.o UtimeWrap_i.o UtimeWrap_m.o UtimeOpsC.o FastNumParse_i.o FastNumParse_m.o -L/usr/local/cm3/pkg/patternmatching/AMD64_DARWIN -lpatternmatching -L/usr/local/cm3/pkg/libbuf/AMD64_DARWIN -llibbuf -L/usr/local/cm3/pkg/rdwr/AMD64_DARWIN -lrdwr -L/usr/local/cm3/pkg/set/AMD64_DARWIN -lset -L/usr/local/cm3/pkg/cit_common/AMD64_DARWIN -lcit_common -L/usr/local/cm3/pkg/netobj/AMD64_DARWIN -lm3netobj -L/usr/local/cm3/pkg/tcp/AMD64_DARWIN -lm3tcp -L/usr/local/cm3/pkg/libm3/AMD64_DARWIN -lm3 -L/usr/local/cm3/pkg/m3core/AMD64_DARWIN -lm3core -lSystem Undefined symbols for architecture x86_64:

My clang is:

clang version 7.0.1 (tags/RELEASE_701/final) Target: x86_64-apple-darwin18.2.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473305062, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpUexp1JPo4Ox8oS6qTSRy2tMy9_gks5vW6zHgaJpZM4b1aCr .

brakmic commented 5 years ago

If I only knew where I could find compiler commands there? If it's in the same output then I can search for it, no problem. Regarding clang, well, I assume that the compiler flags are the same, but what I have experienced so far in other projects is that the subsequent linking sometimes fails when certain flags are present. Like those I mentioned before: -dn and -dy I don't mean that these must have been the reason for this problem, just that I once had to deal with those macOS-extras.

mikanystrom commented 5 years ago

It's probably in your .log or something... you can try this:

cd cit_util rm -rf AMD64_DARWIN cm3 |& tee cm3.log grep CTZ cm3.log

On Fri, Mar 15, 2019 at 3:57 PM Harris Brakmić notifications@github.com wrote:

If I only knew where I could find compiler commands there? If it's in the same output then I can search for it, no problem. Regarding clang, well, I assume that the compiler flags are the same, but what I have experienced so far in other projects it that the subsequent linking sometimes fails when certain flags are present. Like those I mentioned before: -dn and -dy I don't mean that these must have been the reason for this problem, just that I once had to deal with those macOS-extras.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473342159, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpc98EzxCx6igPLF4e7nvugJaaUkQks5vW8L8gaJpZM4b1aCr .

brakmic commented 5 years ago

Thanks! Here the grep output for CTZ:

g++ -g -fPIC -Wall -Werror -Wno-return-type -Wno-missing-braces -m64 -arch x86_64 -x c++ -funwind-tables -I/usr/local/cm3/pkg/m3core/src/unix/Common -I/usr/local/cm3/pkg/m3core/src -I/usr/local/cm3/pkg/m3core/src/Csupport/Common -I/usr/local/cm3/pkg/m3core/src/Csupport/little-endian -I/usr/local/cm3/pkg/m3core/src/Csupport/libgcc -I/usr/local/cm3/pkg/m3core/src/runtime/common -I/usr/local/cm3/pkg/m3core/src/runtime/POSIX -I/usr/local/cm3/pkg/m3core/src/runtime/ex_frame -I/usr/local/cm3/pkg/m3core/src/thread/Common -I/usr/local/cm3/pkg/m3core/src/thread/PTHREAD -I/usr/local/cm3/pkg/m3core/src/C/Common -I/usr/local/cm3/pkg/m3core/src/float/C99 -I/usr/local/cm3/pkg/m3core/src/time/POSIX -I/usr/local/cm3/pkg/libm3/src/os/POSIX -I/usr/local/cm3/pkg/libm3/src/uid/POSIX -I/usr/local/cm3/pkg/tcp/src/POSIX -I/usr/local/cm3/pkg/patternmatching/src/libglob -I../src -g -c ../src/CTZ.c -o CTZ.o
mikanystrom commented 5 years ago

yep, try running that exact command but replacing g++ with gcc.. like this:

cd AMD64_DARWIN gcc -g -fPIC

then re-link by running cm3

does that change anything?

On Fri, Mar 15, 2019 at 4:02 PM Harris Brakmić notifications@github.com wrote:

Thanks! Here the grep output for CTZ:

g++ -g -fPIC -Wall -Werror -Wno-return-type -Wno-missing-braces -m64 -arch x86_64 -x c++ -funwind-tables -I/usr/local/cm3/pkg/m3core/src/unix/Common -I/usr/local/cm3/pkg/m3core/src -I/usr/local/cm3/pkg/m3core/src/Csupport/Common -I/usr/local/cm3/pkg/m3core/src/Csupport/little-endian -I/usr/local/cm3/pkg/m3core/src/Csupport/libgcc -I/usr/local/cm3/pkg/m3core/src/runtime/common -I/usr/local/cm3/pkg/m3core/src/runtime/POSIX -I/usr/local/cm3/pkg/m3core/src/runtime/ex_frame -I/usr/local/cm3/pkg/m3core/src/thread/Common -I/usr/local/cm3/pkg/m3core/src/thread/PTHREAD -I/usr/local/cm3/pkg/m3core/src/C/Common -I/usr/local/cm3/pkg/m3core/src/float/C99 -I/usr/local/cm3/pkg/m3core/src/time/POSIX -I/usr/local/cm3/pkg/libm3/src/os/POSIX -I/usr/local/cm3/pkg/libm3/src/uid/POSIX -I/usr/local/cm3/pkg/tcp/src/POSIX -I/usr/local/cm3/pkg/patternmatching/src/libglob -I../src -g -c ../src/CTZ.c -o CTZ.o

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473343883, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpQXgcvo6X0acf0XhivARH3Rcqnnaks5vW8QKgaJpZM4b1aCr .

brakmic commented 5 years ago

Have tried it, but same error:

      _SysPerf__DiskAvail in SysPerf_m.o
  "_getloadavg_glue", referenced from:
      _SysPerf__GetLoadAvg in SysPerf_m.o
  "_printf_prints", referenced from:
      _RTRefStats__Visit in RTRefStats_m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rm libcit_util.a
  make_lib => 1
  make_lib => 1
librarian failed building: cit_util
Fatal Error: package build failed
brakmic commented 5 years ago

But I think this has to do with the fact that macOS always uses clang even if one types gcc. One must separately install GCC.

Will try it now and report the results.

mikanystrom commented 5 years ago

no wait, are you sure? didn't all the errors relating to CTZ go away as a result of recompiling CTZ.c with "gcc" instead of with "g++"????

On Fri, Mar 15, 2019 at 4:10 PM Harris Brakmić notifications@github.com wrote:

But I think this has to do with the fact that macOS always uses clang even if one types gcc. One must separately install GCC.

Will try it now and report the results.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473346979, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpSabhHgowSVpGcNJ4B6Xs3VHnVgXks5vW8YDgaJpZM4b1aCr .

brakmic commented 5 years ago

I've only tried it with GCC no G++. Have also tried it with explicitly installed GCC-7, but still the same error.

brakmic commented 5 years ago

This was the last call I made:

gcc-7 -g -fPIC -Wall -Werror -Wno-return-type -Wno-missing-braces -m64 -arch x86_64 -x c++ -funwind-tables -I/usr/local/cm3/pkg/m3core/src/unix/Common -I/usr/local/cm3/pkg/m3core/src -I/usr/local/cm3/pkg/m3core/src/Csupport/Common -I/usr/local/cm3/pkg/m3core/src/Csupport/little-endian -I/usr/local/cm3/pkg/m3core/src/Csupport/libgcc -I/usr/local/cm3/pkg/m3core/src/runtime/common -I/usr/local/cm3/pkg/m3core/src/runtime/POSIX -I/usr/local/cm3/pkg/m3core/src/runtime/ex_frame -I/usr/local/cm3/pkg/m3core/src/thread/Common -I/usr/local/cm3/pkg/m3core/src/thread/PTHREAD -I/usr/local/cm3/pkg/m3core/src/C/Common -I/usr/local/cm3/pkg/m3core/src/float/C99 -I/usr/local/cm3/pkg/m3core/src/time/POSIX -I/usr/local/cm3/pkg/libm3/src/os/POSIX -I/usr/local/cm3/pkg/libm3/src/uid/POSIX -I/usr/local/cm3/pkg/tcp/src/POSIX -I/usr/local/cm3/pkg/patternmatching/src/libglob -I../src -g -c ../src/CTZ.c -o CTZ.o
brakmic commented 5 years ago

Btw. I just saw this flag here (in the above line): -x c++ Not sure what its meaning is.

brakmic commented 5 years ago

The compilation with G++7 fails the same way.

mikanystrom commented 5 years ago

Check the symbol names with nm, see what is being generated in CTZ.o ... try with and without -x c++...

Your goal if you go down this path is to figure out how to make the errors relating to CTZ go away in the following error dump. In particular, can you make this error go away by playing with how you compile CTZ.c

"_CTZ__setTZ", referenced from: _TZ__SetCurTZ in TZ_m.o _TZ_M3 in TZ_m.o

If you can, you need to adjust the config files to use whatever command string you settle on for all C compilations.

Here is what you reported originally---the question is, did the CTZ related issues go away or not, after you compiled with "gcc" instead of with "g++"?

-> archiving libcit_util.a Undefined symbols for architecture x86_64: "_UtimeOpsCdelete_T", referenced from: _UtimeWrapdelete_T in UtimeWrap_m.o "_UtimeOpsCmake_T", referenced from: _UtimeWrapmake_T in UtimeWrap_m.o "_UtimeOpsCcheck_types", referenced from: _UtimeOpsC_M3 in UtimeOpsC_m.o "_UtimeOpsCGet_second", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_minute", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_hour", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_month", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_year", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsC__mktime", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCGet_wday", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCSet_second", referenced from: _TZMktime in TZ_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCSet_day", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCGet_gmtoff", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCSet_month", referenced from: _TZMktime in TZ_m.o "_CTZsetTZ", referenced from: _TZSetCurTZ in TZ_m.o _TZ_M3 in TZ_m.o "_UtimeOpsCGet_zone", referenced from: _UCTimectime in UCTime_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCwrite_double_clock", referenced from: _UCTimectime in UCTime_m.o "_UtimeOpsCSet_year", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCSet_minute", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCctime_r", referenced from: _UCTimectime in UCTime_m.o "_UtimeOpsCGet_day", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsClocaltime_r", referenced from: _UCTimectime in UCTime_m.o _TZMktime in TZ_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCSet_hour", referenced from: _TZMktime in TZ_m.o "_diskAvail", referenced from: _SysPerfDiskAvail in SysPerf_m.o "_getloadavg_glue", referenced from: _SysPerfGetLoadAvg in SysPerf_m.o "_printf_prints", referenced from: _RTRefStats__Visit in RTRefStats_m.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make_lib => 1

On Fri, Mar 15, 2019 at 4:16 PM Harris Brakmić notifications@github.com wrote:

I've only tried it with GCC no G++. Have also tried it with explicitly installed GCC-7, but still the same error.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473348379, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpRjr21GZhNuS05HXswrTJzLrCchHks5vW8bggaJpZM4b1aCr .

brakmic commented 5 years ago

OK, I will try to find a way. So far no compiler was able to generate the binaries. Must be some flag/option that allows name mangling.

mikanystrom commented 5 years ago

run from the command line, gcc, g++, -x whatever... try a few things (read the manual!!!)

Clearly the linker is expecting a symbol called precisely

_CTZ__setTZ

(no more, no less). Can you make such a symbol appear in CTZ.o? You just need to get your compiler to turn off name mangling somehow.

Another alternative (but it's a pain) is to go through ALL the C code in the CM3 repo and use the methods in m3core.h (look at that file if you like). I think there is some magic there that allows C files to be compiled as C++ without getting mangled. I don't like this approach because AMD64_LINUX doesn't need to go through this so AMD64_DARWIN shouldn't need it either.

The goal is in any case exactly the same. The .i3 is basically setting the expectation that the symbol be called _CTZ__setTZ . We have to meet that expectation somehow with whatever it is that is compiling the C file.

I don't think this is a clang vs. GCC issue. It's a matter of using the right compiler setup (or source code) to force the symbols to come out with "normal C names".

On Fri, Mar 15, 2019 at 4:20 PM Mika Nystrom mika.nystrom@gmail.com wrote:

Check the symbol names with nm, see what is being generated in CTZ.o ... try with and without -x c++...

Your goal if you go down this path is to figure out how to make the errors relating to CTZ go away in the following error dump. In particular, can you make this error go away by playing with how you compile CTZ.c

"_CTZ__setTZ", referenced from: _TZ__SetCurTZ in TZ_m.o _TZ_M3 in TZ_m.o

If you can, you need to adjust the config files to use whatever command string you settle on for all C compilations.

Here is what you reported originally---the question is, did the CTZ related issues go away or not, after you compiled with "gcc" instead of with "g++"?

-> archiving libcit_util.a Undefined symbols for architecture x86_64: "_UtimeOpsCdelete_T", referenced from: _UtimeWrapdelete_T in UtimeWrap_m.o "_UtimeOpsCmake_T", referenced from: _UtimeWrapmake_T in UtimeWrap_m.o "_UtimeOpsCcheck_types", referenced from: _UtimeOpsC_M3 in UtimeOpsC_m.o "_UtimeOpsCGet_second", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_minute", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_hour", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_month", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCGet_year", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsC__mktime", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCGet_wday", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCSet_second", referenced from: _TZMktime in TZ_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCSet_day", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCGet_gmtoff", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsCSet_month", referenced from: _TZMktime in TZ_m.o "_CTZsetTZ", referenced from: _TZSetCurTZ in TZ_m.o _TZ_M3 in TZ_m.o "_UtimeOpsCGet_zone", referenced from: _UCTimectime in UCTime_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCwrite_double_clock", referenced from: _UCTimectime in UCTime_m.o "_UtimeOpsCSet_year", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCSet_minute", referenced from: _TZMktime in TZ_m.o "_UtimeOpsCctime_r", referenced from: _UCTimectime in UCTime_m.o "_UtimeOpsCGet_day", referenced from: _TZLocaltime in TZ_m.o "_UtimeOpsClocaltime_r", referenced from: _UCTimectime in UCTime_m.o _TZMktime in TZ_m.o _TZLocaltime in TZ_m.o "_UtimeOpsCSet_hour", referenced from: _TZMktime in TZ_m.o "_diskAvail", referenced from: _SysPerfDiskAvail in SysPerf_m.o "_getloadavg_glue", referenced from: _SysPerfGetLoadAvg in SysPerf_m.o "_printf_prints", referenced from: _RTRefStats__Visit in RTRefStats_m.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make_lib => 1

On Fri, Mar 15, 2019 at 4:16 PM Harris Brakmić notifications@github.com wrote:

I've only tried it with GCC no G++. Have also tried it with explicitly installed GCC-7, but still the same error.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473348379, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpRjr21GZhNuS05HXswrTJzLrCchHks5vW8bggaJpZM4b1aCr .

mikanystrom commented 5 years ago

You could try replacing this line in Darwin.common

SYSTEM_CC = "g++ -g -fPIC"

with

SYSTEM_CC = "gcc -g -fPIC" SYSTEM_CXXC = "g++ -g -fPIC"

On Fri, Mar 15, 2019 at 4:25 PM Harris Brakmić notifications@github.com wrote:

OK, I will try to find a way. So far no compiler was able to generate the binaries. Must be some flag/option that allows name mangling.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473351756, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpZVEqr_mji__KqkzxWqcdVoL6L8qks5vW8j0gaJpZM4b1aCr .

mikanystrom commented 5 years ago

and yeah this line is suspicious too. I don't really know the best way here. Try a few things...

SYSTEM_CC = SYSTEM_CC & " -x c++"

On Fri, Mar 15, 2019 at 4:31 PM Mika Nystrom mika.nystrom@gmail.com wrote:

You could try replacing this line in Darwin.common

SYSTEM_CC = "g++ -g -fPIC"

with

SYSTEM_CC = "gcc -g -fPIC" SYSTEM_CXXC = "g++ -g -fPIC"

On Fri, Mar 15, 2019 at 4:25 PM Harris Brakmić notifications@github.com wrote:

OK, I will try to find a way. So far no compiler was able to generate the binaries. Must be some flag/option that allows name mangling.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473351756, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpZVEqr_mji__KqkzxWqcdVoL6L8qks5vW8j0gaJpZM4b1aCr .

brakmic commented 5 years ago

I will try them all. Many thanks! 👍

brakmic commented 5 years ago

So far it seems that we have to do with "C name mangling" and "C++ name mangling".

When I add extern "C" to prevent C++ name mangling we then get:

0000000000000054 T _CTZ__setTZ
0000000000000000 T _CTZ__setenv_TZ_America_New_York

This is what I added to CTZ.c to deactivate C++ name mangling:

extern "C" {
    void CTZ__setenv_TZ_America_New_York(void);
    void CTZ__setTZ(const char *tzname);
}

Without extern C the exported functions would look like this:

0000000000000054 T __Z10CTZ__setTZPKc
0000000000000000 T __Z31CTZ__setenv_TZ_America_New_Yorkv

So I've tried to make it compile by changing CTZ.i3 to accept C-mangled functions by adding the underscore:

<*EXTERNAL _CTZ__setTZ *>
PROCEDURE setTZ(name : const_char_star);

<*OBSOLETE*>
<*EXTERNAL _CTZ__setenv_TZ_America_New_York *>
PROCEDURE setenv_TZ_America_New_York();

...sadly, it throws yet another error:

checking UtimeOpsC.c
checking libcit_util.a

****  PARALLEL BACK-END BUILD, M3_PARALLEL_BACK = 20
rm libcit_util.5.dylib
ln -s libcit_util.5.2.dylib libcit_util.5.dylib
rm libcit_util.dylib
ln -s libcit_util.5.dylib libcit_util.dylib
  skip_lib => 0

compilation failed => not building library "libcit_util.a"
Fatal Error: package build failed

 seconds  #times  operation
    0.04      10  inhaling library link info
    0.18       1  getting derived timestamps
    0.01     378  checking old link info
    0.01     363  merging new link info
    0.03       2  compiling Modula-3 -> IL
    0.05       3  garbage collection
---------------------------------------------------
    0.35          TOTAL
mikanystrom commented 5 years ago

I think you may be adding an extra underscore.

If you look at one of your previous emails, you had:

U _CTZ__setTZ

that was failing. See the leading underscore? It's normal for the underscore to be prepended.

I don't see what the error is in the last case you pasted. There's no error there, it just said it failed. The error might be further up somewhere?

Let me ask this: if you just compile CTZ.c the way it is checked in, but use "gcc" instead of "g++", and do NOT use "-x c++", what symbols are exported by CTZ.o? From what you have above, try this:

gcc -g -fPIC -Wall -Werror -Wno-return-type -Wno-missing-braces -m64 -arch x86_64 -funwind-tables -I/usr/local/cm3/pkg/m3core/src/unix/Common -I/usr/local/cm3/pkg/m3core/src -I/usr/local/cm3/pkg/m3core/src/Csupport/Common -I/usr/local/cm3/pkg/m3core/src/Csupport/little-endian -I/usr/local/cm3/pkg/m3core/src/Csupport/libgcc -I/usr/local/cm3/pkg/m3core/src/runtime/common -I/usr/local/cm3/pkg/m3core/src/runtime/POSIX -I/usr/local/cm3/pkg/m3core/src/runtime/ex_frame -I/usr/local/cm3/pkg/m3core/src/thread/Common -I/usr/local/cm3/pkg/m3core/src/thread/PTHREAD -I/usr/local/cm3/pkg/m3core/src/C/Common -I/usr/local/cm3/pkg/m3core/src/float/C99 -I/usr/local/cm3/pkg/m3core/src/time/POSIX -I/usr/local/cm3/pkg/libm3/src/os/POSIX -I/usr/local/cm3/pkg/libm3/src/uid/POSIX -I/usr/local/cm3/pkg/tcp/src/POSIX -I/usr/local/cm3/pkg/patternmatching/src/libglob -I../src -g -c ../src/CTZ.c -o CTZ.o

On Fri, Mar 15, 2019 at 5:31 PM Harris Brakmić notifications@github.com wrote:

So far it seems that we have to do with "C name mangling" and "C++ name mangling".

When I add extern "C" to prevent C++ name mangling we then get:

0000000000000054 T _CTZ__setTZ 0000000000000000 T _CTZ__setenv_TZ_America_New_York

This is what I added to CTZ.c to deactivate C++ name mangling:

extern "C" { void CTZsetenv_TZ_America_New_York(void); void CTZsetTZ(const char *tzname); }

Without extern C the exported functions would look like this:

0000000000000054 T Z10CTZsetTZPKc 0000000000000000 T Z31CTZsetenv_TZ_America_New_Yorkv

So I've trued to make it compile by changing CTZ.i3 to accept C-mangled functions by adding the underscore:

<EXTERNAL _CTZ__setTZ >PROCEDURE setTZ(name : const_char_star);

<OBSOLETE> <EXTERNAL _CTZ__setenv_TZ_America_New_York >PROCEDURE setenv_TZ_America_New_York();

...sadly, it throws yet another error:

checking UtimeOpsC.c checking libcit_util.a **** PARALLEL BACK-END BUILD, M3_PARALLEL_BACK = 20 rm libcit_util.5.dylib ln -s libcit_util.5.2.dylib libcit_util.5.dylib rm libcit_util.dylib ln -s libcit_util.5.dylib libcit_util.dylib skip_lib => 0

compilation failed => not building library "libcit_util.a" Fatal Error: package build failed

seconds #times operation 0.04 10 inhaling library link info 0.18 1 getting derived timestamps 0.01 378 checking old link info 0.01 363 merging new link info 0.03 2 compiling Modula-3 -> IL 0.05 3 garbage collection

0.35          TOTAL

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473376532, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpaY7LLd89Al_vB8C-oEx51d91jhDks5vW9jwgaJpZM4b1aCr .

brakmic commented 5 years ago

When I compile it with GCC I get the same C-mangled functions.

0000000000000054 T _CTZ__setTZ
0000000000000000 T _CTZ__setenv_TZ_America_New_York

I think I should simply try to compile everything again, but with prepended underscores and "extern C". Just to see if it works.

mikanystrom commented 5 years ago

No, the "C mangling" (leading underscore) is absolutely normal. That should link fine.

Look at TZ.o -- you should see U _CTZ__setTZ there, which matches T _CTZ__setTZ in CTZ.o. That should link just fine..!

On Fri, Mar 15, 2019 at 5:54 PM Harris Brakmić notifications@github.com wrote:

When I compile it with GCC I get the same C-mangled functions.

0000000000000054 T _CTZ__setTZ 0000000000000000 T _CTZ__setenv_TZ_America_New_York

I think I should simply try to compile everything again, but with appended underscores and "extern C". Just to see if it works.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/46#issuecomment-473384525, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWGpWTEoEYFc9RZDXZ4l7843jeIXsCHks5vW95AgaJpZM4b1aCr .

brakmic commented 5 years ago

Yes, this is what I am hoping for. Ideally, there would be no need to change anything in compiler configuration files. If it compiles with the two changes from above then maybe one could make a few changes for macOS (if this issue happens on macs only).