Yeah it built libalu_d.so ok (it's in the directory); it's not linking though
Code:$ ls 1st.mak alu.h alu_int_d.o alu_math_d.o alu_uint_d.o cloned libalu_d.so test_d.o GNUmakefile alu_bit.c alu_main.c alu_mem.c alu_vec.c dst_cc.mak main.mak LICENSE alu_bit_d.o alu_main_d.o alu_mem_d.o alu_vec_d.o dst_sys.mak makefile README.md alu_int.c alu_math.c alu_uint.c char.mak func.mak test.c
Strange, I honestly suck at makefiles (despite using them in every project) so I don't know what to do about that, as far as I can see gcc should find it without issue as the directory itself is included via the '-L .' and the library should've been correctly referenced via '-l alu_d', if you got any ideas just give it a try, let me know if something causes it to link, I'll incorporate it into mine and upload it
Hi,
I did clone your repo, and tried building it with just "make" and had no success:
So I short-cut it all:Code:.... test.c:(.text+0x4529): undefined reference to `alu_str2int' test.c:(.text+0x45c7): undefined reference to `alu_int2str' test.c:(.text+0x46a3): undefined reference to `alu_rem_reg_node' test.o: In function `print_value': test.c:(.text+0x48d4): undefined reference to `alu_block' test.c:(.text+0x4c22): undefined reference to `alu_block' test.c:(.text+0x4d78): undefined reference to `alu_block' test.o: In function `main': test.c:(.text+0x4e55): undefined reference to `alu_setup_reg' test.c:(.text+0x4ffc): undefined reference to `alu_vec' collect2: error: ld returned 1 exit status main.mak:91: recipe for target 'alu.AppImage' failed make[3]: *** [alu.AppImage] Error 1 1st.mak:6: recipe for target 'build' failed make[2]: *** [build] Error 2 main.mak:68: recipe for target 'all' failed make[1]: *** [all] Error 2 1st.mak:6: recipe for target 'all' failed make: *** [all] Error 2
I now also get your issue:Code:~/alu$ gcc -o alu *.c -I cloned/fbstdc/include ~/alu$
So now I compiled with warnings turned up to 11:Code::~/alu$ ./alu test.c:1341: main() Pre-allocating 32 ALU registers... test.c:698: compare() 'Comparing values...' test.c:699: compare() '===========================================' *** stack smashing detected ***: <unknown> terminated Aborted (core dumped)
I get 556 lines of warning where dodgy stuff is going on. You really want to fix all of thoses before you start any serious debugging.Code:gcc -o alu *.c -I cloned/fbstdc/include -Wall -pedantic -O4
But seriously: I'm more then willing to help you get this into shape, but do you really want my help?
I do know a bit of this stuff - if you want, have a look at my toy RISCV RV32I CPU's ALU.
Rudi-RV32I/alu.vhd at master * hamsternz/Rudi-RV32I * GitHub
Last edited by hamster_nz; 09-15-2020 at 04:15 PM.
I actually forgot that flag existed, considering the type of project it is there's no real reason for me to not add it in and leave it there permanently, already helping me identify a bunch of bugs introduced while I was changing the core API, dealing with them now, some on the other hand are minor and safe to ignore (fixing 'em anyways though)
Well I tried adding the profiling as a target/goal, as you might have guessed I didn't succeed:
Any ideas why it failed?Code:make profile run MAKECMDGOALS=profile run make -j 1 --no-print-directory -f main.mak profile run PRJ_SRC_FILES = 'test.c alu_bit.c alu_int.c alu_main.c alu_math.c alu_mem.c alu_uint.c alu_vec.c' Checking 3rd Party libraries are upto date cd 'cloned/fbstdc' && git config pull.rebase true && git pull Already up to date. Finished checking PRJ_DST_BIN=alu_p.AppImage PRJ_DST_LIB=libalu_p.so make[1]: Nothing to be done for 'profile'. gprof ./alu_p.AppImage gmon.out: No such file or directory make[1]: *** [main.mak:83: run] Error 1 make: *** [1st.mak:6: profile] Error 2 Compilation failed.
That was because I had done a rebuildall prior to that however looking at another rebuild I noticed that I failed to actually add the variable holding the flags, having done that the output now looks like this:
Code:make profile run MAKECMDGOALS=profile run make -j 1 --no-print-directory -f main.mak profile run PRJ_SRC_FILES = 'test.c alu_bit.c alu_int.c alu_main.c alu_math.c alu_mem.c alu_uint.c alu_vec.c' Checking 3rd Party libraries are upto date cd 'cloned/fbstdc' && git config pull.rebase true && git pull Already up to date. Finished checking PRJ_DST_BIN=alu_p.AppImage PRJ_DST_LIB=libalu_p.so cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o test_p.o -c test.c cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o alu_bit_p.o -c alu_bit.c cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o alu_int_p.o -c alu_int.c cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o alu_main_p.o -c alu_main.c cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o alu_math_p.o -c alu_math.c cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o alu_mem_p.o -c alu_mem.c cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o alu_uint_p.o -c alu_uint.c cc -D NDEBUG -pg -fPIC -Wall -Wextra -pedantic -I cloned/fbstdc/include -o alu_vec_p.o -c alu_vec.c cc -D NDEBUG -pg -fPIC -shared -o libalu_p.so alu_bit_p.o alu_int_p.o alu_main_p.o alu_math_p.o alu_mem_p.o alu_uint_p.o alu_vec_p.o -Wl,-rpath=./ cc -D NDEBUG -pg -fPIE -L . -o alu_p.AppImage test_p.o -Wl,-rpath=./ -l alu_p gprof ./alu_p.AppImage gmon.out: No such file or directory make[1]: *** [main.mak:83: run] Error 1 make: *** [1st.mak:6: profile] Error 2 Compilation failed.