Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: build on OpenBSD 7.6 fails 'Error: static assert: "Websocket server not implemented...' #2977

Closed
lfzamora81 opened this issue Nov 16, 2024 · 35 comments · Fixed by #2978
Closed
Labels
Bug Something isn't working Compiler Issue Fixed
Milestone

Comments

@lfzamora81
Copy link

Describe the bug

Trying to build from source for OpenBSD 7.6

Used bash configure since default OpenBSD ksh produces errors.

Then use gmake clean; gmake; for the same reason.

However, these then produce the following output including errors:

rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
if [ -f .git/HEAD ] ; then \
        git describe --tags > version ; \
else \                                                                                                                                                                                        
        echo v2.5.2 > version ; \                                                                                                                                                             
fi                                                                                                                                                                                            
dmd -w -J. -O -L-L/usr/local/lib -L-lcurl -L-L/usr/local/lib -L-lsqlite3  -L-ldl src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/webhook.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive                                                                                              
src/arsd/cgi.d(7002): Error: static assert:  "Websocket server not implemented on this system yet (email me, i can prolly do it if you need it)"                                              
src/arsd/cgi.d(7097):        instantiated from here: `startAddonServer!()`                                                                                                                    
src/arsd/cgi.d-mixin-7412(7483):        instantiated from here: `openLocalServerConnection!()`                                                                                                
gmake: *** [Makefile:106: onedrive] Error 1

Operating System Details

OpenBSD obsd.***.com 7.6 GENERIC.MP#338 amd64

Client Installation Method

From Source

OneDrive Account Type

Personal

What is your OneDrive Application Version

N/A

What is your OneDrive Application Configuration

N/A

What is your 'curl' version

curl 8.10.1 (x86_64-unknown-openbsd7.6) libcurl/8.10.1 LibreSSL/4.0.0 zlib/1.3.1.1-motley nghttp2/1.63.0 ngtcp2/1.7.0 nghttp3/1.5.0
Release-Date: 2024-09-18
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HSTS HTTP2 HTTP3 HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe UnixSockets

Where is your 'sync_dir' located

Local

What are all your system 'mount points'

/dev/sd0a on / type ffs (local)
/dev/sd0l on /home type ffs (local, nodev, nosuid)
/dev/sd0d on /tmp type ffs (local, nodev, nosuid)
/dev/sd0f on /usr type ffs (local, nodev)
/dev/sd0g on /usr/X11R6 type ffs (local, nodev)
/dev/sd0h on /usr/local type ffs (local, nodev, wxallowed)
/dev/sd0k on /usr/obj type ffs (local, nodev, nosuid)
/dev/sd0j on /usr/src type ffs (local, nodev, nosuid)
/dev/sd0e on /var type ffs (local, nodev, nosuid)

What are all your local file system partition types

type: SCSI
disk: SCSI disk
label: WDC PC SN530 SDB
duid: a9c324f0c921e150
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 31130
total sectors: 500118192
boundstart: 532544
boundend: 500118159

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  a:          2097152           532544  4.2BSD   2048 16384 12960 # /
  b:         16625408          2629696    swap                    # none
  c:        500118192                0  unused                    
  d:          8388608         19255104  4.2BSD   2048 16384 12960 # /tmp
  e:         40590848         27643712  4.2BSD   2048 16384 12960 # /var
  f:         50669184         68234560  4.2BSD   2048 16384 12960 # /usr
  g:          2097152        118903744  4.2BSD   2048 16384 12960 # /usr/X11R6
  h:         41943040        121000896  4.2BSD   2048 16384 12960 # /usr/local
  i:           532480               64   MSDOS                    
  j:         10485760        162943936  4.2BSD   2048 16384 12960 # /usr/src
  k:         12582912        173429696  4.2BSD   2048 16384 12960 # /usr/obj
  l:        314105536        186012608  4.2BSD   4096 32768 26062 # /home

How do you use 'onedrive'

N/A

Steps to reproduce the behaviour

  1. Start with a baseline OpenBSD 7.6 installation.
  2. Install Git-2.46.1 from ports.
  3. This installs Curl-8.10.1 as dependency.
  4. Install DMD-2.109.0 from ports.
  5. Install libnotify-0.8.3 from ports.
  6. doas pkg_add bash version 5.2.32. (this may have actually been
  7. doas pkg_add gmake version 4.4.1.
  8. Clone onedrive repo to build directory (/home//build in my case)
  9. cd into onedrive directory
  10. bash configure
  11. gmake clean; gmake

Complete Verbose Log Output

N/A

Screenshots

onedrive gmake

Other Log Information or Details

No response

Additional context

No response

@lfzamora81 lfzamora81 added the Bug Something isn't working label Nov 16, 2024
@abraunegg
Copy link
Owner

@lfzamora81
Unfortunately this is something from the dependency from the arsd repository.

Please note that FreeBSD does not encounter such issue, given those packages, so I wonder what the difference is here.

@adamdruppe
Can you suggest a fix here for arsd/cgi.d build error above in function void startAddonServer() ?

@abraunegg abraunegg added this to the v2.5.4 milestone Nov 16, 2024
@adamdruppe
Copy link

I don't think you use the websocket server here so you will want to disable it.

These lines right here enable optional features:

https://github.com/abraunegg/onedrive/blob/master/src/arsd/cgi.d#L579

Compile it with -version=minimal or simply delete those three lines from your copy of the file and it should work for you.

@abraunegg
Copy link
Owner

@lfzamora81

Please can you test PR #2978 to resolve your issue.

To clone the PR to potentially resolve your issue, you can use a script like the following:

#!/bin/bash

PR=2978

rm -rf ./onedrive-pr${PR}
git clone https://github.com/abraunegg/onedrive.git onedrive-pr${PR}
cd onedrive-pr${PR}
git fetch origin pull/${PR}/head:pr${PR}
git checkout pr${PR}

# Configure and Build
./configure --enable-debug --enable-notifications; make clean; make;
./onedrive --version

When running the PR, your version should be: onedrive v2.5.3-1-gaeb0a0e or greater.

If you can report back regarding this fix that would be greatly appreciated.

@adamdruppe

Thanks for the suggestion. I took a slightly different route (not deleting those lines), to use the OS version itself in a similar manner to FreeBSD as not to potentially impact Linux use.

@lfzamora81
Copy link
Author

So @adamdruppe @abraunegg both your fixes work to get past the initial issue but then a compiler (DMD) bug seems to crop up. I may try to use LDC or file a bug with DMD (as the output suggests, lol)

I did have to modify the script slightly to account for ksh and gmake but other than that it appears to have run as expected with the error coming from DMD.

Of course it is odd that there are 'out of memory' errors on a system with 8GB of ram and not much else running.

Here is the full output:

obsd$ ./fix                                                                                                                                                                                  
Cloning into 'onedrive-pr2978'...
remote: Enumerating objects: 8532, done.
remote: Counting objects: 100% (192/192), done.
remote: Compressing objects: 100% (119/119), done.
remote: Total 8532 (delta 97), reused 127 (delta 68), pack-reused 8340 (from 1)
Receiving objects: 100% (8532/8532), 9.42 MiB | 5.57 MiB/s, done.
Resolving deltas: 100% (5954/5954), done.
From https://github.com/abraunegg/onedrive
 * [new ref]         refs/pull/2978/head -> pr2978
Switched to branch 'pr2978'
checking for a BSD-compatible install... /usr/bin/install -c
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for dmd... dmd
checking version of D compiler... 2.109.0
checking for curl... yes
checking for sqlite... yes
checking for notify... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating contrib/pacman/PKGBUILD
config.status: creating contrib/spec/onedrive.spec
config.status: creating onedrive.1
config.status: creating contrib/systemd/onedrive.service
config.status: creating contrib/systemd/onedrive@.service
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
if [ -f .git/HEAD ] ; then \
        git describe --tags > version ; \
else \
        echo v2.5.3 > version ; \
fi
dmd -w -J. -g -debug -gs -version=NoPragma -version=NoGdk -version=Notifications -L-L/usr/local/lib -L-lcurl -L-L/usr/local/lib -L-lsqlite3 -L-L/usr/local/lib -L-lnotify -L-lgdk_pixbuf-2.0 -L-lgio-2.0 -L-lgobject-2.0 -L-lglib-2.0 -L-lintl -L-ldl src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/webhook.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d src/notifications/notify.d src/notifications/dnotify.d -ofonedrive
---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.
---
DMD v2.109.0

predefs   NoPragma NoGdk Notifications DigitalMars LittleEndian D_Version2 all D_SIMD Posix ELFv1 OpenBSD CppRuntime_Clang D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_PreConditions D_PostConditions D_Invariants D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    dmd
version   v2.109.0

config    /etc/dmd.conf
DFLAGS    -I/usr/local/include/dmd/phobos -I/usr/local/include/dmd/druntime/import -L-L/usr/lib -L-L/usr/local/lib -L--export-dynamic -fPIC
---
core.exception.AssertError@src/dmd/common/outbuffer.d(190): OutBuffer: out of memory.
----------------
??:? _d_assert_msg [0xe9a6a569ff0]
??:? OutBuffer::reserve(unsigned long) [0xe9a6a559502]
??:? pure nothrow @trusted void dmd.common.outbuffer.OutBuffer.write(scope const(void)[]) [0xe9a6a55976e]
??:? OutBuffer::write(void const*, unsigned long) [0xe9a6a559723]
??:? nothrow void dmd.backend.elfobj.ElfObj_addrel(int, ulong, uint, uint, ulong) [0xe9a6a532d25]
??:? nothrow ulong dmd.backend.elfobj.ElfObj_writerel(int, ulong, uint, uint, ulong) [0xe9a6a5331f9]
??:? nothrow int dmd.backend.elfobj.ElfObj_reftoident(int, ulong, dmd.backend.cc.Symbol*, ulong, int) [0xe9a6a533bb8]
??:? nothrow int dmd.backend.obj.Obj.reftoident(int, ulong, dmd.backend.cc.Symbol*, ulong, int) [0xe9a6a436f9c]
??:? nothrow @trusted void dmd.backend.cod3.do32bit(ref dmd.backend.cod3.MiniCodeBuf, ubyte, ref dmd.backend.code.evc, int, int) [0xe9a6a503d4b]
??:? nothrow @trusted uint dmd.backend.cod3.codout(int, dmd.backend.code_x86.code*, dmd.backend.barray.Barray!(ubyte).Barray*) [0xe9a6a502a9e]
??:? nothrow @trusted void dmd.backend.cgcod.codgen(dmd.backend.cc.Symbol*) [0xe9a6a4cce70]
??:? nothrow @trusted void dmd.backend.dout.writefunc2(dmd.backend.cc.Symbol*) [0xe9a6a47fb21]
??:? nothrow @trusted void dmd.backend.dout.writefunc(dmd.backend.cc.Symbol*) [0xe9a6a47f45a]
??:? void dmd.glue.FuncDeclaration_toObjFile(dmd.func.FuncDeclaration, bool) [0xe9a6a413d1b]
??:? toObjFile::ToObjFile::visit(FuncDeclaration*) [0xe9a6a42d46d]
??:? FuncDeclaration::accept(Visitor*) [0xe9a6a322d15]
??:? void dmd.toobj.toObjFile(dmd.dsymbol.Dsymbol, bool).ToObjFile.visit(dmd.dclass.ClassDeclaration).__lambda3!(dmd.dsymbol.Dsymbol).__lambda3(dmd.dsymbol.Dsymbol) [0xe9a6a42d8e5]
??:? void dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*, void delegate(dmd.dsymbol.Dsymbol)) [0xe9a6a2a159b]
??:? toObjFile::ToObjFile::visit(ClassDeclaration*) [0xe9a6a42d5b0]
??:? ClassDeclaration::accept(Visitor*) [0xe9a6a261cd1]
??:? void dmd.toobj.toObjFile(dmd.dsymbol.Dsymbol, bool) [0xe9a6a42d3d4]
??:? void dmd.glue.genObjFile(dmd.dmodule.Module, bool) [0xe9a6a411c7c]
??:? void dmd.glue.generateCodeAndWrite(dmd.dmodule.Module[], const(char)*[], const(char)[], const(char)[], bool, bool, bool, bool, bool) [0xe9a6a41002e]
??:? int dmd.main.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0xe9a6a217de2]
??:? _Dmain [0xe9a6a216540]
core.exception.OutOfMemoryError@src/core/internal/gc/impl/conservative/gc.d(2230): Memory allocation failed
----------------
??:? onOutOfMemoryError [0xe9a6a569f10]
??:? nothrow @nogc void core.internal.gc.impl.conservative.gc.Gcx.ToScanStack!(core.internal.gc.impl.conservative.gc.Gcx.ScanRange!(false).ScanRange).ToScanStack.grow() [0xe9a6a57f05c]
??:? nothrow @nogc scope void core.internal.gc.impl.conservative.gc.Gcx.mark!(false, false, false).mark(core.internal.gc.impl.conservative.gc.Gcx.ScanRange!(false).ScanRange) [0xe9a6a57ed2e]
??:? nothrow @nogc scope void core.internal.gc.impl.conservative.gc.Gcx.markConservative!(false).markConservative(void*, void*) [0xe9a6a57e91d]
??:? nothrow @nogc int core.internal.gc.impl.conservative.gc.Gcx.markAll!(core.internal.gc.impl.conservative.gc.Gcx.markConservative!(false).markConservative(void*, void*)).markAll().__foreachbody2(ref core.gc.gcinterface.Range) [0xe9a6a57e8db]
??:? nothrow int core.internal.container.treap.Treap!(core.gc.gcinterface.Range).Treap.opApply(scope int delegate(ref core.gc.gcinterface.Range) nothrow).__lambda2(ref const(core.gc.gcinterface.Range)) [0xe9a6a57d13b]
??:? nothrow int core.internal.container.treap.Treap!(core.gc.gcinterface.Range).Treap.opApplyHelper(const(core.internal.container.treap.Treap!(core.gc.gcinterface.Range).Treap.Node*), int delegate(ref const(core.gc.gcinterface.Range)) nothrow) [0xe9a6a57d4f3]
??:? nothrow int core.internal.container.treap.Treap!(core.gc.gcinterface.Range).Treap.opApply(scope int delegate(ref core.gc.gcinterface.Range) nothrow) [0xe9a6a57d10d]
??:? nothrow void core.internal.gc.impl.conservative.gc.Gcx.markAll!(core.internal.gc.impl.conservative.gc.Gcx.markConservative!(false).markConservative(void*, void*)).markAll() [0xe9a6a57e875]
??:? nothrow ulong core.internal.gc.impl.conservative.gc.Gcx.fullcollect(bool, bool) [0xe9a6a578679]
??:? nothrow ulong core.internal.gc.impl.conservative.gc.ConservativeGC.runLocked!(core.internal.gc.impl.conservative.gc.ConservativeGC.fullCollect().go(core.internal.gc.impl.conservative.gc.Gcx*), core.internal.gc.impl.conservative.gc.Gcx*).runLocked(ref core.internal.gc.impl.conservative.gc.Gcx*) [0xe9a6a5821eb]
??:? nothrow ulong core.internal.gc.impl.conservative.gc.ConservativeGC.fullCollect() [0xe9a6a5752d7]
??:? nothrow void core.internal.gc.impl.conservative.gc.ConservativeGC.collect() [0xe9a6a5752b5]
??:? gc_term [0xe9a6a58ba18]
??:? rt_term [0xe9a6a58b82e]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0xe9a6a58abfc]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0xe9a6a58aad9]
??:? _d_run_main2 [0xe9a6a58aa3a]
??:? _d_run_main [0xe9a6a58a823]
??:? main [0xe9a6a2164fb]
gmake: *** [Makefile:106: onedrive] Error 1
./fix: line 13: ./onedrive: No such file or directory

@lfzamora81
Copy link
Author

@adamdruppe

How do I compile with -version=minimal? That does not appear to be an option when I run bash configure --help. I only see --enable-notifications and --enable-completions as listed enable options.

Even so, would it be possible to not have to compile a minimal version? Is there a way to leave in or allow Websockets as the log output suggests? What features are lost with a "minimal" version?

@adamdruppe
Copy link

I just provided the library file, I don't know how it is built here. (and since it is a generic library, it includes a lot more features than any one individual project tends to use) But that linked PR achieves the same goal anyway, opting out of the websocket class for the openbsd OS. So it'd have the same result anyway.

The compiler out of memory thing has some other cause. It isn't uncommon for the D compiler to use several gigabytes of ram though, it might be legitimately running out. (and odds are most its allocations are huge blocks of zeroes... on linux when dmd runs out of memory, i enable this zram feature that compresses pages and cuts memory use down to like 1/10th. If openbsd has similar you might try that and see what happens)

@abraunegg
Copy link
Owner

@lfzamora81

Of course it is odd that there are 'out of memory' errors on a system with 8GB of ram and not much else running.

To compile the application manually you must comply with the requirements as per https://github.com/abraunegg/onedrive/blob/master/docs/install.md#building-from-source---high-level-requirements

  • At least 1GB free system memory
  • At least 1GB swap space

Do you have any swap space allocated - I cant see this in your OpenBSD filesystem layout.

@lfzamora81
Copy link
Author

@abraunegg
According to top I have 5.6GB free memory.

swapctl -l shows 8GB of swap space, none of it used at the moment.

Unrelated to this issue, I did order a memory upgrade so should have 16GB of memory soon. If it works after the upgrade, there's definitely a need for more than 1GB of system and swap space =P Or something else weird going on.

@abraunegg
Copy link
Owner

@adamdruppe

zram feature

How do you enable this feature / capability in the DMD / LDC compiler - I dont see anything referred to that in the help / compiler options.

@adamdruppe
Copy link

It is a linux kernel module, not a compiler feature. I don't know if openbsd has something similar or not. reference https://wiki.archlinux.org/title/Improving_performance#zram_or_zswap

@adamdruppe
Copy link

Worth noting that the out of memory thing could also be a simple compiler bug; more often than not in user code, out of memory means you tried to do something like array.length = -1 (since -1 wraps around to the maximum 64 bit number...) and maybe something similar done here. I don't have enough info to say.

@lfzamora81
Copy link
Author

zram is apparently not a feature in either FreeBSD or OpenBSD as far as my limited Google-fu is telling me.

I did submit a bug to DMD with reference to this issue for further background: https://issues.dlang.org/show_bug.cgi?id=24863

Question: is there a way to choose between the DMD or LDC compiler using the configure script or other method? Or do I simply need to un-install DMD and then install LDC so it only picks up the latter?

@abraunegg
Copy link
Owner

@lfzamora81

@abraunegg According to top I have 5.6GB free memory.

swapctl -l shows 8GB of swap space, none of it used at the moment.

Unrelated to this issue, I did order a memory upgrade so should have 16GB of memory soon. If it works after the upgrade, there's definitely a need for more than 1GB of system and swap space =P Or something else weird going on.

Unfortunately I am out of suggestions for you then at this point in time.

The 'out-of-memory' error always was being seen on ARM builds due to no swap space being available.

@rikkimax
Copy link

Doesn't look like it.

The realloc is failing, not malloc.

I don't think it its OOM, just that the allocator is placing things differently and causing the realloc to fail after a certain amount allocated.

@abraunegg
Copy link
Owner

@lfzamora81

Question: is there a way to choose between the DMD or LDC compiler using the configure script or other method? Or do I simply need to un-install DMD and then install LDC so it only picks up the latter?

The configure script will detect which compiler is installed / activated

@rikkimax
Copy link

@lfzamora81

Question: is there a way to choose between the DMD or LDC compiler using the configure script or other method? Or do I simply need to un-install DMD and then install LDC so it only picks up the latter?

The configure script will detect which compiler is installed / activated

LDC will not exhibit this issue.

The exception stack trace shows a dmd only issue (or at least I'm pretty sure ldc won't be calling into OutBuffer for object file creation).

@lfzamora81
Copy link
Author

When attempting to install ldc-1.35.0p0 from ports:

===> ldc-1.35.0p0 is marked as broken: needs new bootstrap .

sad trombone

@abraunegg
Copy link
Owner

@lfzamora81

is marked as broken: needs new bootstrap

What about installing LDC this way:

curl -fsS https://dlang.org/install.sh | bash -s ldc

@lfzamora81
Copy link
Author

@abraunegg

Unsupported OS OpenBSD

sadder trombone

@abraunegg
Copy link
Owner

@lfzamora81

Your path of resolution then looks like this:

  1. Speak with the maintainer of ldc for OpenBSD and get them to remediate / fix / update / get it operational
  2. Attempt to build the client again using the fixed LDC compiler for OpenBSD

I will leave this issue ticket open

@rikkimax
Copy link

Related: ldc-developers/ldc#4435

@abraunegg
Copy link
Owner

@lfzamora81
Given that the original issue , the provided PR you were able to progress further, I will merge that PR into 'master' so that when you get around to having a working compiler on OpenBSD , you can clone directly from 'master' and not worry about any other changes made post that particular PR as I do not know how long it will take to resolve the 'ldc' compiler issue on OpenBSD.

@abraunegg abraunegg modified the milestones: v2.5.4, v2.5.x Nov 16, 2024
@abraunegg abraunegg linked a pull request Nov 16, 2024 that will close this issue
@lfzamora81
Copy link
Author

@abraunegg

Sounds good. I will continue to monitor progress on the LDC on OpenBSD issue as well as the bug submitted for DMD and whichever resolves first, move forward with it to test and see where we end up.

@lfzamora81
Copy link
Author

So that's a bit embarrassing. I got a clue from a reply from the ports mailing list (in regard to DMD, LDC still broken with no comment about it) about increasing data size limits in /etc/login.conf, apparently OpenBSD has low defaults:

https://marc.info/?l=openbsd-ports&m=173180799125734&w=2

After increasing datasize-cur and datasize-max for the defaults, the compilation moved forward but then came across a missing library ldl:

obsd$ gmake clean; gmake;
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
if [ -f .git/HEAD ] ; then \
        git describe --tags > version ; \
else \
        echo v2.5.3 > version ; \
fi
dmd -w -J. -O -L-L/usr/local/lib -L-lcurl -L-L/usr/local/lib -L-lsqlite3  -L-ldl src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/webhook.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive
ld: error: unable to find library -ldl
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
       cc onedrive.o -Wl,--no-execute-only -Wl,-z,nobtcfi -o onedrive -m64 -Xlinker --export-dynamic -L/usr/local/lib -lcurl -L/usr/local/lib -lsqlite3 -ldl -L/usr/lib -L/usr/local/lib -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lc++abi -lexecinfo
gmake: *** [Makefile:106: onedrive] Error 1

The ldl library is a Linux thing apparently and there is no OpenBSD equivalent (so far as I can tell...). So shot in the dark, I removed the reference in the Makefile (-L-ldl) but then ran into these errors:

obsd$ gmake clean; gmake;
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
if [ -f .git/HEAD ] ; then \
        git describe --tags > version ; \
else \
        echo v2.5.3 > version ; \
fi
dmd -w -J. -O -L-L/usr/local/lib -L-lcurl -L-L/usr/local/lib -L-lsqlite3  src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/webhook.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive
ld: error: undefined symbol: inotify_init
>>> referenced by src/arsd/cgi.d
>>>               onedrive.o:(_D7monitor23MonitorBackgroundWorker10initialiseMOFZv)

ld: error: undefined symbol: inotify_add_watch
>>> referenced by src/arsd/cgi.d
>>>               onedrive.o:(_D7monitor23MonitorBackgroundWorker15addInotifyWatchMOFAyaZi)

ld: error: undefined symbol: inotify_rm_watch
>>> referenced by src/arsd/cgi.d
>>>               onedrive.o:(_D7monitor23MonitorBackgroundWorker18removeInotifyWatchMOFiZi)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Error: undefined reference to `inotify_init`
Error: undefined reference to `inotify_add_watch`
Error: undefined reference to `inotify_rm_watch`
       perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)`
Error: linker exited with status 1
       cc onedrive.o -Wl,--no-execute-only -Wl,-z,nobtcfi -o onedrive -m64 -Xlinker --export-dynamic -L/usr/local/lib -lcurl -L/usr/local/lib -lsqlite3 -L/usr/lib -L/usr/local/lib -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic -lpthread -lm -lc++abi -lexecinfo
gmake: *** [Makefile:106: onedrive] Error 1

@adamdruppe
Copy link

I'm just about to shut down for bed, but it said inotify is from cgi.d but it doesn't use it - note the mangled name shows it comes from in here: https://github.com/abraunegg/onedrive/blob/master/src/monitor.d#L7

bsd's kqueue function can do similar to inotify but it isn't a drop in replacement.

@abraunegg
Copy link
Owner

@lfzamora81

Thats correct - this comes from the inotify support which is required to monitor file changes on Linux.

I wonder what/how the FreeBSD port is solving this ....

@lfzamora81
Copy link
Author

@abraunegg

Maybe devel/libinotify? It's listed on the FreeBSD port library dependencies and also is available on OpenBSD:

https://www.freshports.org/net/onedrive/

Port:   libinotify-20211018
Path:   devel/libinotify
Info:   kevent based inotify
Maint:  Kirill Bychkov <kirby@openbsd.org>
Index:  devel
L-deps: 
B-deps: devel/autoconf/2.69 devel/automake/1.14 devel/dwz devel/libtool devel/metaauto
R-deps: 
Archs:  any

@abraunegg
Copy link
Owner

@lfzamora81
That probably will be the one required

@abraunegg
Copy link
Owner

@lfzamora81
I would also ensure installing all the same/similar dependencies as FreeBSD

@lfzamora81
Copy link
Author

I installed all the same dependencies listed for FreeBSD but still getting the same errors. Perhaps if I knew what to modify the ldl dependency into?

What is the Free/OpenBSD library equivalent? Maybe if I can find the FreeBSD Makefile or install it on VM and take a look...

@lfzamora81
Copy link
Author

Success!

After some digging around I found that the -ldl library is replaced on the *BSDs by libinotify-kqueue (https://github.com/libinotify-kqueue/libinotify-kqueue). On OpenBSD the library is in ports as simply libinotify. So I removed the -L-ldl part from the Makefile line and after installing the libinotify port, added -L/usr/local/lib/inotify -linotify to the notify_LIBS variable. This could probably be done by replacing the -L-ldl part too.

Compiled quickly and without error but then got a runtime error:

obsd$ onedrive --version
ld.so: onedrive: can't load library 'libinotify.so.3.0'
Killed 

Hmmm. So I did some digging and found that the libinotify port installs in an odd place--it adds a sub-directory under the standard search path of runtime libraries: /usr/local/lib/inotify This requires adding that location to the ld search path of which there are a number of ways to do so: https://man.openbsd.org/ldconfig.8

After that, it worked!

obsd$ onedrive --version
onedrive v2.5.3-1-gaeb0a0e

@rikkimax
Copy link

Congrats, well done!

@abraunegg
Copy link
Owner

Well done on building on OpenBSD. Please let me know if any other issues arise.

Would you be able to create a PR to document how you built so it could be added here: https://github.com/abraunegg/onedrive/blob/master/docs/install.md#building-from-source---high-level-requirements ?

@lfzamora81
Copy link
Author

@abraunegg

Ah, good call. Yeah, I will work on adding an OpenBSD section to that doc page soon.

@abraunegg
Copy link
Owner

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Repository owner locked as resolved and limited conversation to collaborators Nov 25, 2024
@abraunegg abraunegg modified the milestones: v2.5.x, v2.5.4 Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Compiler Issue Fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants