Closed gpatrickb closed 5 years ago
IIRC OpenBSD 6.2 is still beta. aye? and the guys have done a ton of changes in LibC and compiler default flags.
Yes, 6.2 still hasn't been released, but should be sometime within the month. OpenBSD 6.2 amd64 compiles fine, just i386 needs the int changed to long.
I don't have a OpenBSD 6.2 i386 box. I'll setup a VM within the next days and work with @norayr to fix the issues and let you know. might be even a perfect time to setup Pledge interface in voc to use in OpenBSD.
I appreciate your help.
@dcwbrown dealt with hard to find openbsd related bugs a lot. would you comment on this, David?
OpenBSD 6.2 being in beta is irrelevant. The problem is the #ifdefs typedef'ing size_t in voc's two SYSTEM.h files. voc typedef's size_t to be unsigned int for 32-bit architectures but on OpenBSD size_t is an unsigned long, and this mismatch confuses clang (the default compiler for OpenBSD).
ok, previously we had separate SYSTEM.h for each architecture/os, now @dcwbrown merged those in to one, based in src/runtime. So if we change one file, it may break other systems. Let's wait for David's comment.
Sorry for delay, just got back. Will look at this tomorrow.
Not really...
All you have to do is change:
// Declare memcpy in a way compatible with C compilers intrinsic
// built in implementations.
#if defined (o__64)
#if defined(_WIN64)
typedef unsigned long long size_t;
#else
typedef unsigned long size_t;
#endif
#else
typedef unsigned int size_t;
#endif
to this:
// Declare memcpy in a way compatible with C compilers intrinsic
// built in implementations.
#if defined (o__64)
#if defined(_WIN64)
typedef unsigned long long size_t;
#else
typedef unsigned long size_t;
#endif
#else
#if defined(__OpenBSD__)
typedef unsigned long size_t;
#else
typedef unsigned int size_t;
#endif
#endif
Thanks @ibara, that works nicely. Do you know if this is OpenBSD specific, or would also apply to other BSDs?
It looks to be OpenBSD-specific. BTW, there's a handy site you can use to look up such things, http://bxr.su (That's how I looked it up for Free/Net/DFly).
BTW, going forward, you will want to change your OpenBSD buildbot from
export CC=gcc
to
export CC=cc
since the in-base gcc 4.2.1 could go away at any time in the future, and cc has always been the preferred in-base compiler name. And cc is now clang in 6.2 and beyond.
Why the entire code uses condition #if defined(__OpenBSD__)
?
#ifdef __OpenBSD__
looks shorter in this place.
Is there any difference?
Probably my question is most addressed to the Dave Brown, author of the code.
P.S. I know about the possibility of logical operations between defined() && defined(), but if only one condition is specified?
There is no functional difference between
#if defined(__OpenBSD__)
and
#ifdef __OpenBSD__
for the single case.
However, if the list needs to grow, then the #ifdef construct is no good. And you don't know if the list will need to grow in the future. No one does. So why not write the construct with growth in mind, in case that becomes necessary?
Additionally, I chose the #if construct because right above it is an
#if defined(_WIN64)
and I will always prefer to follow the style of a project instead of imposing my own as an outsider.
It's just another slightly irritating example of C's ad hoc short term choices making things unnecessarily complex. As you know there's actually 3 ways header files commonly manage conditional compilation:
#if fred // When fred had been defined as zero or non zero
#ifdef bert // when bert is defined or not defined
#if defined(harry) // needed when a combination of conditions are required
As @ibara says if defined() has the advantage of being consistent between single and multiple condition cases.
Arguably C ended up with little messes like this because it was grown incrementally while remaining compatible with existing code. It would be nice if could have learned more from Pascal, though at the time Pascal was being developed on CDC mainframes and C on DEC minis so Pascal would have not felt particularly relevant.
Pascal/Modula/Oberon were built with smaller goals, more experimenting and prototyping and without a need to support code written for intermediate versions, and this allowed them to be simpler. Not that the removal of complexity is trivial - I don't think there are many others with Wirth's determination for simplicity.
So when I read code with a mixture of #if, #ifdef and #if defined, I have a little grumble at the extra effort it will be to work out which code will be compiled, and indulge myself in a little smug righteousness about preferring With's languages.
@ibara: Thanks for proposing export CC=cc
: I'm guessing you've tried this, but could you confirm?
@dcwbrown: I have not tried this. I've never used voc. I'm just an OpenBSD developer.
Thank you everyone. It was a pleasure to read these comments. (:
The error during compilation below is fixed by: Change line 22 in bootstrap/SYSTEM.h and src/runtime/SYSTEM.h from: typedef unsigned int size_t; to: typedef unsigned long size_t;
Compilation output: In file included from src/tools/make/configure.c:15: src/runtime/SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ src/runtime/SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' src/runtime/SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ src/runtime/SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. Configuration: 2.1.0 [2017/09/03] for clang ILP32 on openbsd Branch: master.
--- Cleaning branch master openbsd clang ILP32 ---
--- Compiler build started ---
Populating clean build directory from bootstrap C sources unix-44.
make assemble - compiling Oberon compiler c source: VERSION: 2.1.0 BRANCH: master Target characteristics: PLATFORM: unix OS: openbsd BUILDDIR: build/openbsd.ILP32.clang INSTALLDIR: /usr/local/share/voc Oberon characteristics: MODEL: 2 ADRSIZE: 4 ALIGNMENT: 4 C compiler: COMPILER: clang COMPILE: clang -fPIC -g DATAMODEL: ILP32 In file included from SYSTEM.c:16: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Configuration.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Platform.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Heap.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Out.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Reals.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Strings.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Modules.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Files.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Texts.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from VT100.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from OPM.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from extTools.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from OPS.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from OPT.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from OPC.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from OPV.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from OPB.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from OPP.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. In file included from Compiler.c:8: ./SYSTEM.h:28:7: warning: incompatible redeclaration of library function 'memcpy' [-Wincompatible-library-redeclaration] void memcpy(void dest, const void source, size_t size); ^ ./SYSTEM.h:28:7: note: 'memcpy' is a builtin with type 'void (void , const void , unsigned long)' ./SYSTEM.h:32:7: warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration] void alloca(size_t size); ^ ./SYSTEM.h:32:7: note: 'alloca' is a builtin with type 'void (unsigned long)' 2 warnings generated. Heap.o: In function
Heap_FreeModule': /tmp/voc/build/openbsd.ILP32.clang/Heap.c:154: undefined reference to
alloca' Out.o: In functionOut_String': /tmp/voc/build/openbsd.ILP32.clang/Out.c:74: undefined reference to
alloca' Out.o: In functionOut_prepend': /tmp/voc/build/openbsd.ILP32.clang/Out.c:164: undefined reference to
alloca' Strings.o: In functionStrings_Length': /tmp/voc/build/openbsd.ILP32.clang/Strings.c:30: undefined reference to
alloca' Strings.o: In functionStrings_Append': /tmp/voc/build/openbsd.ILP32.clang/Strings.c:48: undefined reference to
alloca' Strings.o:/tmp/voc/build/openbsd.ILP32.clang/Strings.c:65: more undefined references to `alloca' follow clang: error: linker command failed with exit code 1 (use -v to see invocation) Error 1 in . (src/tools/make/oberon.mk:71 'assemble': cd build/openbsd.ILP32.clang && clang -fPIC -g -static Compiler.c -o /tmp/voc/voc ...) Error 1 in . (src/tools/make/oberon.mk:86 'compilerfromsavedsource') *** Error 1 in /tmp/voc (makefile:140 'full')