ngn/k
19
63
Fork
You've already forked k
17

building macos ventura #67

Open
opened 2023年10月18日 10:40:05 +02:00 by mkm · 4 comments

I run on macos ventura, and my default environment comes with Apple clang version 14.0.3.

Just running make doesn't work:

$ gmake
gmake MAKEFLAGS=-j8 k && gmake MAKEFLAGS=-j8 t #default target
gmake[1]: Entering directory '/Users/mkm/Build/k'
gmake MAKEFLAGS=-j8 a N=k R=k O='-O3 -march=native -Wl,-E' L='-lm -ldl'
gmake[2]: Entering directory '/Users/mkm/Build/k'
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/0.o -c 0.c
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/1.o -c 1.c
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/2.o -c 2.c
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/3.o -c 3.c
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/4.o -c 4.c
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/a.o -c a.c
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/b.o -c b.c
mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/e.o -c e.c
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
gmake[2]: *** [makefile:7: o/k/1.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: *** [makefile:7: o/k/3.o] Error 1
gmake[2]: *** [makefile:7: o/k/4.o] Error 1
gmake[2]: *** [makefile:7: o/k/0.o] Error 1
gmake[2]: *** [makefile:7: o/k/2.o] Error 1
gmake[2]: *** [makefile:7: o/k/b.o] Error 1
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]
gmake[2]: *** [makefile:7: o/k/e.o] Error 1
gmake[2]: *** [makefile:7: o/k/a.o] Error 1
gmake[2]: Leaving directory '/Users/mkm/Build/k'
gmake[1]: *** [makefile:4: k] Error 2
gmake[1]: Leaving directory '/Users/mkm/Build/k'
gmake: *** [makefile:3: 0] Error 2

I see in the readme that the recommended way to build on is to pass CC=clang-11 or CC=gcc-10
I'm trying to figure out how to build ngn/k without having to install clang-11 or gcc-10.

I'll report my findings here

I run on macos ventura, and my default environment comes with `Apple clang version 14.0.3`. Just running `make` doesn't work: ```console $ gmake gmake MAKEFLAGS=-j8 k && gmake MAKEFLAGS=-j8 t #default target gmake[1]: Entering directory '/Users/mkm/Build/k' gmake MAKEFLAGS=-j8 a N=k R=k O='-O3 -march=native -Wl,-E' L='-lm -ldl' gmake[2]: Entering directory '/Users/mkm/Build/k' mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/0.o -c 0.c mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/1.o -c 1.c mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/2.o -c 2.c mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/3.o -c 3.c mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/4.o -c 4.c mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/a.o -c a.c mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/b.o -c b.c mkdir -p o/k;cc @opts -O3 -march=native -Wl,-E -o o/k/e.o -c e.c clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] gmake[2]: *** [makefile:7: o/k/1.o] Error 1 gmake[2]: *** Waiting for unfinished jobs.... gmake[2]: *** [makefile:7: o/k/3.o] Error 1 gmake[2]: *** [makefile:7: o/k/4.o] Error 1 gmake[2]: *** [makefile:7: o/k/0.o] Error 1 gmake[2]: *** [makefile:7: o/k/2.o] Error 1 gmake[2]: *** [makefile:7: o/k/b.o] Error 1 clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] gmake[2]: *** [makefile:7: o/k/e.o] Error 1 gmake[2]: *** [makefile:7: o/k/a.o] Error 1 gmake[2]: Leaving directory '/Users/mkm/Build/k' gmake[1]: *** [makefile:4: k] Error 2 gmake[1]: Leaving directory '/Users/mkm/Build/k' gmake: *** [makefile:3: 0] Error 2 ``` I see in the readme that the recommended way to build on is to pass `CC=clang-11` or `CC=gcc-10` I'm trying to figure out how to build ngn/k without having to install clang-11 or gcc-10. I'll report my findings here
Author
Copy link

quick&dirty way to get it building:

diff --git makefile makefile
index fd9e6404..867b1924 100644
--- makefile
+++ makefile
@@ -1,7 +1,7 @@
 MAKE:=$(MAKE) MAKEFLAGS=-j8
 M=mkdir -p $(@D)
 0:;$(MAKE) k && $(MAKE) t #default target
-k:;$(MAKE) a N=$@ R=k O='-O3 -march=native -Wl,-E' L='-lm -ldl'
+k:;$(MAKE) a N=$@ R=k O='-O3 -march=native ' L='-lm -ldl'
 libk.so:;$(MAKE) a N=$@ R=$@ O='-fPIC -Dshared -lm' L='-lm -ldl -shared'
 libk.a:;$(MAKE) b N=$@ R=$@ O='-O3 -march=native -ffreestanding -lm -ldl -Dldstatic'
 o/$N/%.o:%.c *.h;$M;$(CC) @opts $O -o $@ -c $<
quick&dirty way to get it building: ```diff diff --git makefile makefile index fd9e6404..867b1924 100644 --- makefile +++ makefile @@ -1,7 +1,7 @@ MAKE:=$(MAKE) MAKEFLAGS=-j8 M=mkdir -p $(@D) 0:;$(MAKE) k && $(MAKE) t #default target -k:;$(MAKE) a N=$@ R=k O='-O3 -march=native -Wl,-E' L='-lm -ldl' +k:;$(MAKE) a N=$@ R=k O='-O3 -march=native ' L='-lm -ldl' libk.so:;$(MAKE) a N=$@ R=$@ O='-fPIC -Dshared -lm' L='-lm -ldl -shared' libk.a:;$(MAKE) b N=$@ R=$@ O='-O3 -march=native -ffreestanding -lm -ldl -Dldstatic' o/$N/%.o:%.c *.h;$M;$(CC) @opts $O -o $@ -c $< ```

In OpenBSD, I also remove those flags, though I also have to remove the -ldl one, because the dl* functions in OpenBSD are in libc, there is no libdl library. It seems like using the same build options in all platforms is not possible. I don't know what the best portability fix for this is, I don't know much about linking stuff. Not a big deal, though, it's easy to change that line each time I update.

In OpenBSD, I also remove those flags, though I also have to remove the `-ldl` one, because the `dl*` functions in OpenBSD are in libc, there is no libdl library. It seems like using the same build options in all platforms is not possible. I don't know what the best portability fix for this is, I don't know much about linking stuff. Not a big deal, though, it's easy to change that line each time I update.
Contributor
Copy link

I noticed the same problem on macOS:

clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument]

For a long time, I have been able to build on macOS without any problems. Removing the argument -Wl,-E from the makefile fixes the problem, but there is probably a better solution.

I also tried adding -Wno-unused-command-line-argument to disable the warning that's causing the build failure, but then I get this error:

ld: unknown options: -E 
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm not sure what this linker argument is supposed to do.

I noticed the same problem on macOS: ``` clang: fatal error: -Wl,-E: 'linker' input unused [-Wunused-command-line-argument] ``` For a long time, I have been able to build on macOS without any problems. Removing the argument `-Wl,-E` from the makefile fixes the problem, but there is probably a better solution. I also tried adding `-Wno-unused-command-line-argument` to disable the warning that's causing the build failure, but then I get this error: ``` ld: unknown options: -E clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` I'm not sure what this linker argument is supposed to do.
Collaborator
Copy link

@SirBogman I’m guessing it’s to export dynamic symbols from the executable so they can be called from dynamic libraries. I think this is the default for dylan files. (Not sure of the terminology for this last.)

@SirBogman I’m guessing it’s to [export dynamic symbols](https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html) from the executable so they can be called from dynamic libraries. I think this is the default for dylan files. (Not sure of the terminology for this last.)
ngn referenced this issue from a commit 2023年11月21日 20:41:54 +01:00
Sign in to join this conversation.
No Branch/Tag specified
master
pages
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ngn/k#67
Reference in a new issue
ngn/k
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?