make CC=other_cc in windows - c

maybe this question is stupid but i really am not able to get a way to fix this i am trying to make a file in Cygwin64 i have all the dependency files installed, but when i make the file it throws me this
$ make
x86_64-w64-mingw32-gcc -D OS_WINDOWS_NT -ansi -Wall -O2 -Wno-long-long -I /usr/include -c -o main.o main.c
In file included from /usr/include/sys/_pthreadtypes.h:12,
from /usr/include/sys/types.h:223,
from /usr/include/stdio.h:61,
from main.c:5:
/usr/include/sys/cpuset.h:17:30: error: expected expression before ‘/’ token
17 | #define __CPU_SETSIZE 1024 // maximum number of logical processors tracked
| ^
/usr/include/sys/cpuset.h:19:25: note: in expansion of macro ‘__CPU_SETSIZE’
19 | #define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number
| ^~~~~~~~~~~~~
/usr/include/sys/cpuset.h:26:21: note: in expansion of macro ‘__CPU_GROUPMAX’
26 | __cpu_mask __bits[__CPU_GROUPMAX];
| ^~~~~~~~~~~~~~
/usr/include/sys/cpuset.h:19:55: error: expected expression before ‘/’ token
19 | #define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number
| ^
/usr/include/sys/cpuset.h:26:21: note: in expansion of macro ‘__CPU_GROUPMAX’
26 | __cpu_mask __bits[__CPU_GROUPMAX];
| ^~~~~~~~~~~~~~
/usr/include/sys/cpuset.h:27:1: warning: no semicolon at end of struct or union
27 | } cpu_set_t;
| ^
In file included from /usr/include/errno.h:9,
from main.c:8:
/usr/include/sys/errno.h:14: warning: "errno" redefined
14 | #define errno (*__errno())
|
In file included from /usr/lib/gcc/x86_64-w64-mingw32/10/include/stddef.h:1,
from /usr/include/sys/cdefs.h:47,
from /usr/include/stdio.h:35,
from main.c:5:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/stddef.h:19: note: this is the location of the previous definition
19 | #define errno (*_errno())
|
make: *** [<builtin>: main.o] Error 1

Your problem is that you've added the -ansi option to your compile line:
x86_64-w64-mingw32-gcc -D OS_WINDOWS_NT -ansi ...
The -ansi option tells the compiler to compile your code as if it were ANSI C 89 standard code. That version of the standard did not support the // single-line comment delimiter: it only supports the traditional /* ... */ comments.
However the header file you're including clearly expects to be able to use // comments. So you cannot use the -ansi flag when you compile with these header files.

Related

_ASM_EXTABLE_HANDLE virtualization compilation failure

I'm trying to compile this project from github but I am running into the following error:
make -C /lib/modules/5.15.0-53-generic/build M=/home/jr/Documents/ProtoVirt modules EXTRA_CFLAGS="-g -DDEBUG"
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-53-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
You are using: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
CC [M] /home/jr/Documents/ProtoVirt/protovirt.o
In file included from /home/jr/Documents/ProtoVirt/protovirt.c:23:
/home/jr/Documents/ProtoVirt/protovirt.h: In function ‘__rdmsr1’:
/home/jr/Documents/ProtoVirt/protovirt.h:25:22: error: expected ‘:’ or ‘)’ before ‘_ASM_EXTABLE_HANDLE’
25 | _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe)
| ^~~~~~~~~~~~~~~~~~~
/home/jr/Documents/ProtoVirt/protovirt.h:25:42: error: invalid suffix "b" on integer constant
25 | _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe)
| ^~
/home/jr/Documents/ProtoVirt/protovirt.h:25:46: error: invalid suffix "b" on integer constant
25 | _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe)
| ^~
/home/jr/Documents/ProtoVirt/protovirt.c: In function ‘initVmcsControlField’:
/home/jr/Documents/ProtoVirt/protovirt.c:282:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
282 | void *costum_rip;
| ^~~~
make[2]: *** [scripts/Makefile.build:297: /home/jr/Documents/ProtoVirt/protovirt.o] Error 1
make[1]: *** [Makefile:1903: /home/jr/Documents/ProtoVirt] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-53-generic'
make: *** [Makefile:12: modules] Error 2
The command I'm running is make. Can anyone explain to me what I'm doing wrong?
The _ASM_EXTABLE_HANDLE macro is replaced by _ASM_EXTABLE_TYPE in the newest kernel versions.

Error no member named 'reqevents'; did you mean 'events' when building Redis on AIX

I'm upgrading from Redis 6.0.13 to 6.2.5 on AIX.
On 6.2.5, the build fails with this error:
MAKE hdr_histogram
cd hdr_histogram && make
make[3]: Entering directory '/home/jenkins/redis/deps/hdr_histogram'
/opt/atc-2.0/opt/gcc/bin/gcc -Wall -Os -g -DLUA_USE_POSIX -DLUA_USE_DLOPEN -include stdint-gcc.h -c hdr_histogram.c
make[3]: Leaving directory '/home/jenkins/redis/deps/hdr_histogram'
make[2]: Leaving directory '/home/jenkins/redis/deps'
CC adlist.o
CC quicklist.o
CC ae.o
In file included from ae.c:60:
ae_select.c: In function 'aeApiResize':
ae_select.c:52:37: warning: unused parameter 'eventLoop' [-Wunused-parameter]
52 | static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
| ~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/poll.h:30,
from ae.c:41:
ae_select.c: In function 'aeApiPoll':
ae_select.c:89:43: error: 'aeEventLoop' has no member named 'reqevents'; did you mean 'events'?
89 | aeFileEvent *fe = &eventLoop->events[j];
| ^~~~~~
ae.c: In function 'aeCreateEventLoop':
ae.c:73:16: error: 'aeEventLoop' has no member named 'reqevents'; did you mean 'events'?
73 | eventLoop->events = zmalloc(sizeof(aeFileEvent)*setsize);
| ^~~~~~
...
I checked the eventLoop struct, and it does indeed contain events, but I see the build failing because it's trying to access reqevents. I can't find reqevents anywhere in the project (with grep -R 'reqevents' .)
This error only happens on AIX 7.1 - Linux and macOS both work fine.
Do you know why req would be prepended to the struct members on AIX, and how I might solve the error?

How to compile the demo example of SoLoud library in C?

I planned to use the SoLoud library (https://sol.gfxile.net/soloud/index.html) for my C project. I can't understand how to compile the C demo file contained in
/demos/c_test/
to make it executable.
Can someone help me to understand how to compile it using gcc?
in the demos/c_test/main.c,
I changed:
#include "soloud_c.h"
to
#include "../../include/soloud_c.h"
and it compiled. However, the compiler output the following warnings:
gcc -ggdb3 -Wall -Wextra -Wconversion -pedantic -std=gnu11 -c "main.c" -o "main.o" main.c:
In function ‘generate_sample’:
main.c:72:38: warning: conversion from ‘int’ to ‘float’ may change value [-Wconversion]
72 | buf[i] += (((rand() % 1024) - 512) / 512.0f) *
| ^
main.c:75:36: warning: conversion from ‘int’ to ‘float’ may change value [-Wconversion]
75 | float fade = (44100 * 10 - base) / (44100 * 10.0f);
| ^
main.c: In function ‘main’:
main.c:129:14: warning: unused parameter ‘parc’ [-Wunused-parameter]
129 | int main(int parc, char ** pars)
| ~~~~^~~~
main.c:129:28: warning: unused parameter ‘pars’ [-Wunused-parameter]
129 | int main(int parc, char ** pars)
| ~~~~~~~~^~~~
Compilation finished successfully.
Note: I did not bother to link the executable, however, I did note a few items of interest.
the available libraries are *.dll files, so this is expecting to be compiled/linked under the windows OS.
under the 'bin' directory are the libraries: soloud_x64.dll, soloud_x86.dll and SDL2.dll. I don't know which of these libraries your specific computer will need to include

how to generate hex files from c code and assembly code RISCV

I have some C Codes/ assembly codes and I want to compile it and generate hex files for RISCV pulppissimo. Can anyone help me with the steps for this.
Currently running the hello code
#include <stdio.h>
int main()
{
printf("Hello !\n");
return 0;
}
while compiling using riscv32 using the command riscv32-unknown-elf-gcc hello.c
getting error like this
RISCV/lib/gcc/riscv32-unknown-elf/7.1.1/../../../../riscv32-unknown-elf/bin/ld: cannot open linker script file riscv.ld: No such file or directory
collect2: error: ld returned 1 exit status
There is a perfect example in the git repository for the pulp platform boot code that can be used for answering your question. Since I do not have the toolchain you are using, I am using a toolchain I downloaded from the bootlin web site.
wget https://toolchains.bootlin.com/downloads/releases/toolchains/riscv32-ilp32d/tarballs/riscv32-ilp32d--glibc--bleeding-edge-2020.02-2.tar.bz2
mkdir -p /opt/bootlin
tar jxvf riscv32-ilp32d--glibc--bleeding-edge-2020.02-2.tar.bz2 -C /opt/bootlin
git clone git clone https://github.com/pulp-platform/boot-code
cd boot-code
edit the Makefile, and adjust the following lines in order to reflect the location for the toolchain you are using:
PULP_CC = riscv32-unknown-elf-gcc
PULP_LD = riscv32-unknown-elf-gcc
When using the bootlin toolchain, this would result in the two following lines:
PULP_CC = /opt/bootlin/riscv32-ilp32d--glibc--bleeding-edge-2020.02-2/bin/riscv32-buildroot-linux-gnu-gcc
PULP_LD = /opt/bootlin/riscv32-ilp32d--glibc--bleeding-edge-2020.02-2/bin/riscv32-buildroot-linux-gnu-gcc
The the same Makefile, replace the following line - the code does not compile as is I think:
CFLAGS += -Os -g -fno-jump-tables -I$(CURDIR)/include
by:
CFLAGS += -Os -g -fno-jump-tables -I$(CURDIR)/include -DMCHAN_CMD_ILE_BIT=21 -DMCHAN_CMD_ELE_BIT=20
You can now build the build/bootcode executable:
make
CC boot_code.c
In file included from /home/frant/mnt/git/boot-code/include/hal/chips/pulp/pulp.h:20,
from /home/frant/mnt/git/boot-code/include/hal/pulp.h:27,
from boot_code.c:18:
/home/frant/mnt/git/boot-code/include/hal/riscv/riscv_v5.h: In function ‘hal_cluster_id’:
/home/frant/mnt/git/boot-code/include/hal/riscv/riscv_v5.h:172:10: warning: implicit declaration of function ‘__builtin_pulp_ClusterId’ [-Wimplicit-function-declaration]
172 | return __builtin_pulp_ClusterId();
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/frant/mnt/git/boot-code/include/hal/chips/pulp/pulp.h:21,
from /home/frant/mnt/git/boot-code/include/hal/pulp.h:27,
from boot_code.c:18:
/home/frant/mnt/git/boot-code/include/hal/eu/eu_v3.h: In function ‘evt_read32’:
/home/frant/mnt/git/boot-code/include/hal/eu/eu_v3.h:43:11: warning: implicit declaration of function ‘__builtin_pulp_event_unit_read’ [-Wimplicit-function-declaration]
43 | value = __builtin_pulp_event_unit_read((int *)base, offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC crt0.S
LD /home/frant/mnt/git/boot-code/build/bootcode
./stim_utils.py \
--binary=/home/frant/mnt/git/boot-code/build/bootcode \
--stim-bin=rom.bin \
--area=0x1a000000:0x01000000
Created stimuli generator
Added binary: /home/frant/mnt/git/boot-code/build/bootcode
Added target area: [0x1a000000 -> 0x1b000000]
Handling section (base: 0x1a000000, size: 0x57c)
Bypassing section (base:make
CC boot_code.c
In file included from /home/frant/mnt/git/boot-code/include/hal/chips/pulp/pulp.h:20,
from /home/frant/mnt/git/boot-code/include/hal/pulp.h:27,
from boot_code.c:18:
/home/frant/mnt/git/boot-code/include/hal/riscv/riscv_v5.h: In function ‘hal_cluster_id’:
/home/frant/mnt/git/boot-code/include/hal/riscv/riscv_v5.h:172:10: warning: implicit declaration of function ‘__builtin_pulp_ClusterId’ [-Wimplicit-function-declaration]
172 | return __builtin_pulp_ClusterId();
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/frant/mnt/git/boot-code/include/hal/chips/pulp/pulp.h:21,
from /home/frant/mnt/git/boot-code/include/hal/pulp.h:27,
from boot_code.c:18:
/home/frant/mnt/git/boot-code/include/hal/eu/eu_v3.h: In function ‘evt_read32’:
/home/frant/mnt/git/boot-code/include/hal/eu/eu_v3.h:43:11: warning: implicit declaration of function ‘__builtin_pulp_event_unit_read’ [-Wimplicit-function-declaration]
43 | value = __builtin_pulp_event_unit_read((int *)base, offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC crt0.S
LD /home/frant/mnt/git/boot-code/build/bootcode
./stim_utils.py \
--binary=/home/frant/mnt/git/boot-code/build/bootcode \
--stim-bin=rom.bin \
--area=0x1a000000:0x01000000
Created stimuli generator
Added binary: /home/frant/mnt/git/boot-code/build/bootcode
Added target area: [0x1a000000 -> 0x1b000000]
Handling section (base: 0x1a000000, size: 0x57c)
Bypassing section (base: 0x1c000000, size: 0x1928)
objcopy --srec-len 1 --output-target=srec /home/frant/mnt/git/boot-code/build/bootcode /home/frant/mnt/git/boot-code/build/bootcode.s19
./s19toboot.py /home/frant/mnt/git/boot-code/build/bootcode.s19 boot_code.cde pulp 0x1c000000, size: 0x1928)
objcopy --srec-len 1 --output-target=srec /home/frant/mnt/git/boot-code/build/bootcode /home/frant/mnt/git/boot-code/build/bootcode.s19
./s19toboot.py /home/frant/mnt/git/boot-code/build/bootcode.s19 boot_code.cde pulp
And convert it into Intel Hex format:
/opt/bootlin/riscv32-ilp32d--glibc--bleeding-edge-2020.02-2/bin/riscv32-buildroot-linux-gnu-objcopy --output-target=ihex build/bootcode bootcode.ihex
cat bootcode.ihex
:020000041A00E0
:100000006F0080086F0040086F0000086F00C00795
:100010006F0080076F0040076F0000076F00C00689
../...
:081920000000000000000000BF
:040000051A000000DD
:00000001FF
Now that you have a working example for the pulp platform I think is your target, you should be able to adapt it to your needs.

"Static declaration of ‘memfd_create’ follows non-static declaration" Error while building Linux image using Yocto

I am building Linux Image using Yoctobuild system on Ubuntu 18.04 host machine. I am following steps provided over here. I am building for Colibri iMX6ULL computer-on-module. However, my build has failed and it is showing errors given below
declaration of ‘memfd_create’ follows non-static declaration
| static int memfd_create(const char *name, unsigned int flags)
| ^~~~~~~~~~~~
| In file included from /usr/include/x86_64-linux-gnu/bits/mman-linux.h:115:0,
| from /usr/include/x86_64-linux-gnu/bits/mman.h:45,
| from /usr/include/x86_64-linux-gnu/sys/mman.h:41,
| from /home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/qemu-native/2.10.0-r0/qemu-2.10.0/include/sysemu/os-posix.h:29,
| from /home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/qemu-native/2.10.0-r0/qemu-2.10.0/include/qemu/osdep.h:104,
| from /home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/qemu-native/2.10.0-r0/qemu-2.10.0/util/memfd.c:28:
| /usr/include/x86_64-linux-gnu/bits/mman-shared.h:46:5: note: previous declaration of ‘memfd_create’ was here
| int memfd_create (const char *__name, unsigned int __flags) __THROW;
| ^~~~~~~~~~~~
| /home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/qemu-native/2.10.0-r0/qemu-2.10.0/rules.mak:66: recipe for target 'util/memfd.o' failed
And this error:
| gcc -c -I. -I../lib -I../../git/lib -isystem/home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/e2fsprogs-native/1.43.5-r0/recipe-sysroot-native/usr/include -isystem/home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/e2fsprogs-native/1.43.5-r0/recipe-sysroot-native/usr/include -O2 -pipe -DHAVE_CONFIG_H -I../../git/debugfs/../e2fsck -DDEBUGFS ../../git/debugfs/quota.c -o quota.o
| ../../git/debugfs/../misc/create_inode.c:406:18: error: conflicting types for ‘copy_file_range’
| static errcode_t copy_file_range(ext2_filsys fs, int fd, ext2_file_t e2_file,
| ^~~~~~~~~~~~~~~
| In file included from ../../git/debugfs/../misc/create_inode.c:19:0:
| /usr/include/unistd.h:1110:9: note: previous declaration of ‘copy_file_range’ was here
| ssize_t copy_file_range (int __infd, __off64_t *__pinoff,
| ^~~~~~~~~~~~~~~
| gcc -c -I. -I../lib -I../../git/lib -isystem/home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/e2fsprogs-native/1.43.5-r0/recipe-sysroot-native/usr/include -isystem/home/abhiarora/iohertz/gateway_os/yocto/build/tmp-glibc/work/x86_64-linux/e2fsprogs-native/1.43.5-r0/recipe-sysroot-native/usr/include -O2 -pipe -DHAVE_CONFIG_H -I../../git/debugfs/../e2fsck -DDEBUGFS ../../git/debugfs/xattrs.c -o xattrs.o
| Makefile:422: recipe for target 'create_inode.o' failed
| make[2]: *** [create_inode.o] Error 1
| make[2]: *** Waiting for unfinished jobs....
The packages/tasks that were failed:
e2fsprogs_1.43.5
qemu_2.10.0
Can someone help me? I can't switch to ubuntu 16.04 but I think it should be working with my system as well.
This is a known issue at Toradex and is on the Roadmap, see issue #36657.
Fixes are already in the upstream layers, and we have updated our BSP repo. You can try this branch by using the LinuxImageV2.7-integration branch.

Resources