Compiling kernel using GCC error unknown mnemonic - gcc

AS arch/arm64/mm/proc.o
../arch/arm64/mm/proc.S: Assembler messages:
../arch/arm64/mm/proc.S:283: Error: unknown mnemonic `pte_to_phys' -- `pte_to_phys cur_pmdp,pud'
../arch/arm64/mm/proc.S:302: Error: unknown mnemonic `pte_to_phys' -- `pte_to_phys cur_ptep,pmd'
Fixing an issue error build

Related

GoReleaser cross compilation fails

I'm trying to release my project in both linux and windwos machines without success.
I have tried to explicitly define the -CC to few options but non of them worked in both machines.
Pre installed packages:
sudo apt-get install build-essential
sudo apt-get install gcc-multilib g++-multilib
sudo apt-get install gcc-mingw-w64
In the project i'm using c code which uses these flags in order to selective compilation
//#cgo windows CFLAGS: "-IC:/Program Files/OpenSSL-Win64/include"
//#cgo windows LDFLAGS: "-LC:/Program Files/OpenSSL-Win64/lib" -llibcrypto
//#cgo linux LDFLAGS: -lssl -lcrypto
//#cgo CFLAGS: -Wno-deprecated-declarations
running GoRelaser locally on windows machine will result this error.
⨯ release failed after 24.28s error=failed to build for windows_arm64: exit status 2: # runtime/cgo
gcc_arm64.S: Assembler messages:
gcc_arm64.S:28: Error: no such instruction: `stp x29,x30,[sp,'
gcc_arm64.S:32: Error: too many memory references for `mov'
gcc_arm64.S:34: Error: no such instruction: `stp x19,x20,[sp,'
gcc_arm64.S:37: Error: no such instruction: `stp x21,x22,[sp,'
gcc_arm64.S:40: Error: no such instruction: `stp x23,x24,[sp,'
gcc_arm64.S:43: Error: no such instruction: `stp x25,x26,[sp,'
gcc_arm64.S:46: Error: no such instruction: `stp x27,x28,[sp,'
gcc_arm64.S:50: Error: too many memory references for `mov'
gcc_arm64.S:51: Error: too many memory references for `mov'
gcc_arm64.S:52: Error: too many memory references for `mov'
gcc_arm64.S:54: Error: no such instruction: `blr x20'
gcc_arm64.S:55: Error: no such instruction: `blr x19'
gcc_arm64.S:57: Error: no such instruction: `ldp x27,x28,[sp,'
gcc_arm64.S:60: Error: no such instruction: `ldp x25,x26,[sp,'
gcc_arm64.S:63: Error: no such instruction: `ldp x23,x24,[sp,'
gcc_arm64.S:66: Error: no such instruction: `ldp x21,x22,[sp,'
gcc_arm64.S:69: Error: no such instruction: `ldp x19,x20,[sp,'
gcc_arm64.S:72: Error: no such instruction: `ldp x29,x30,[sp],'
⨯ release failed after 24.28s error=failed to build for windows_arm64: exit status 2: # runtime/cgo
gcc_arm64.S: Assembler messages:
gcc_arm64.S:28: Error: no such instruction: `stp x29,x30,[sp,'
gcc_arm64.S:32: Error: too many memory references for `mov'
gcc_arm64.S:34: Error: no such instruction: `stp x19,x20,[sp,'
gcc_arm64.S:37: Error: no such instruction: `stp x21,x22,[sp,'
gcc_arm64.S:40: Error: no such instruction: `stp x23,x24,[sp,'
gcc_arm64.S:43: Error: no such instruction: `stp x25,x26,[sp,'
gcc_arm64.S:46: Error: no such instruction: `stp x27,x28,[sp,'
gcc_arm64.S:50: Error: too many memory references for `mov'
gcc_arm64.S:51: Error: too many memory references for `mov'
gcc_arm64.S:52: Error: too many memory references for `mov'
gcc_arm64.S:54: Error: no such instruction: `blr x20'
gcc_arm64.S:55: Error: no such instruction: `blr x19'
gcc_arm64.S:57: Error: no such instruction: `ldp x27,x28,[sp,'
gcc_arm64.S:60: Error: no such instruction: `ldp x25,x26,[sp,'
gcc_arm64.S:63: Error: no such instruction: `ldp x23,x24,[sp,'
gcc_arm64.S:66: Error: no such instruction: `ldp x21,x22,[sp,'
gcc_arm64.S:69: Error: no such instruction: `ldp x19,x20,[sp,'
gcc_arm64.S:72: Error: no such instruction: `ldp x29,x30,[sp],'
running GoReleaser locally on ubuntu machine will result
gcc: error: unrecognized command line option ‘-mthreads’; did you mean ‘-pthread’?
GoReleaser:
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=1
goos:
- linux
- windows
archives:
- replacements:
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
By default GoReleaser will attempt to make builds for 386, amd64 and arm64. But your windows machine is likey an amd64/x86_64 machine. Normally this is no issue with Go, but since you are using CGO your C toolchain has to support compilation for arm64, which it doesn't.
You should be able to limit the CPU architectures it attempts to build by adding goarch to your config file:
...
builds:
goarch:
- amd64
...
Cross compiling cgo projects is notoriously difficult and a known limitation of GoReleaser. I recommend taking a look at the cgo cookbook if you have not already done so.
As for the error you are getting on ubuntu, it looks like you C toolchain doesn't have the right dependencies/capabilities to cross compile to windows.
I have not done any CGO cross compilation myself(attempt to avoid it at all costs) so I can't vouch for this tool, but from what I am reading online xgo might be able to help you out.

unsupported directive '.stabs'

I'm compiling my code with clang while compiling i'm getting below error with satbs
:1:8: error: unsupported directive '.stabs'
.stabs "warning",30,0,0,0
^
:2:8: error: unsupported directive '.stabs'
.stabs "_setlocale",1,0,0,0
^

Error while building Linux Kernel 2.6.10 Error: operand type mismatch for `mov'

I am learning writing Linux Kernel Modules and following the book Linux Device Drivers. which instructs building and configure a kernel of 2.6.x . I am using kernel version 2.6.10. I followed the steps on thegeekstuff.com/compile-linux-kernel
i.e. I after untarring in the /usr/src directory, I did
$ make menuconfig #this opened up a gui
then I saved the config without making any changes, in the hope to enforce default configuration and then
$ make.
when I did make, it gave me this error and the warning’
include/asm/mpspec_def.h:78:2: warning: ‘packed’ attribute ignored for field
of type ‘unsigned char[6]’ [-Wattributes]
arch/i386/kernel/process.c: In function ‘show_regs’:
arch/i386/kernel/process.c:259:2: warning: pointer targets in passing argument 2 of ‘show_trace’ differ in signedness [-Wpointer-sign]
include/asm/processor.h:499:6: note: expected ‘long unsigned int *’ but argument is of type ‘long int *
arch/i386/kernel/process.c: Assembler messages:
arch/i386/kernel/process.c:384: Error: operand type mismatch for mov'
arch/i386/kernel/process.c:385: Error: operand type mismatch formov'
arch/i386/kernel/process.c:461: Error: operand type mismatch for `mov'
include/linux/elfcore.h:92: Error: operand type mismatch for mov'
include/linux/elfcore.h:92: Error: operand type mismatch formov'
arch/i386/kernel/process.c:583: Error: operand type mismatch for mov'
arch/i386/kernel/process.c:584: Error: operand type mismatch formov'
arch/i386/kernel/process.c:591: Error: operand type mismatch for mov'
arch/i386/kernel/process.c:592: Error: operand type mismatch formov'
make1: [arch/i386/kernel/process.o] Error 1
make: [arch/i386/kernel] Error 2
I have not written professional kernel code before so I am not sure if I should make any changes in the code. Can anybody help me with why this error occurred and how it can be removed. I used the default kernel config. prior to calling make using make menu-config.
The error in the process.c is in savesegment(fs,p->thread.fs); (all instances of the error are from the same function)
Thanks
It is not clear from your question that what are the exact steps you did.
This error may be due to some issues in configuration.
Please try the following steps and see if it solves the problem:
> make defconfig #Creates a default config based on your machine architecture
> make
I used a kernel version who version was closer to my native kernel version ~ 3.11.1. and used make oldconfig instead. This was easier than figuring out each configuration setting for my architecture.

Enable CONFIG_EARLY_PRINTK and CONFIG_DEBUG_KERNEL in configuration

I enabled CONFIG_EARLY_PRINTK and CONFIG_DEBUG_KERNEL in my TI Sitara board configuration file. While building the uImage the following error comes. Why is it coming?
I tried to find out, but I am not able to figure it out properly.
....
CC arch/arm/kernel/io.o
AS arch/arm/kernel/debug.o
arch/arm/kernel/debug.S: Assembler messages:
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `sub ,r1,r2'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `ldr r1,[,#0]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `ldr r2,[,#4]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#0]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#4]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#8]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#0]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#4]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#8]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#0]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#4]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `str r1,[,#8]'
arch/arm/kernel/debug.S:157: Error: ARM register expected -- `ldr ,[,#8]'
arch/arm/kernel/debug.S:157: Error: shift expression expected -- `add r1,r1,'
arch/arm/kernel/debug.S:157: Error: shift expression expected -- `add r2,r2,'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `sub ,r1,r2'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `ldr r1,[,#0]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `ldr r2,[,#4]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#0]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#4]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#8]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#0]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#4]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#8]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#0]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#4]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `str r1,[,#8]'
arch/arm/kernel/debug.S:173: Error: ARM register expected -- `ldr ,[,#8]'
arch/arm/kernel/debug.S:173: Error: shift expression expected -- `add r1,r1,'
arch/arm/kernel/debug.S:173: Error: shift expression expected -- `add r2,r2,'
make[1]: *** [arch/arm/kernel/debug.o] Error 1
make: *** [arch/arm/kernel] Error 2
Recent mainline kernel versions for the Sitara processor expect the user to specify the DEBUG_LL UART via the kernel configuration. The options for the different board and processor variants show up when you enable EARLY_PRINTK.
The right UART port should also be selected.

Is it possible to build FreeGLUT on Mac OS X?

I'm doing some tutorials on OpenGL that use FreeGLUT.
Apparently this is how you build and install it on the mac:
CPPFLAGS="-I/usr/X11R6/include" ./configure --prefix="${PWD}/../"
make
make install
Unfortunately this on its own gives me an error when I do the make command: Undefined symbols for architecture x86_64
After doing abit of work I've found that an improvement on the first line is:
CPPFLAGS="-I/usr/X11R6/include -L/usr/X11R6/lib" LDFLAGS="-L/usr/X11R6/lib" ./configure --prefix="${PWD}/../"
Unfortunately when I do the make command I'm still getting an error:
gcc -DHAVE_CONFIG_H -I. -I../../.. -I/usr/X11R6/include -L/usr/X11R6/lib -I../../../include -g -O2 -Wall -pedantic -MT smooth_opengl3-smooth_opengl3.o -MD -MP -MF .deps/smooth_opengl3-smooth_opengl3.Tpo -c -o smooth_opengl3-smooth_opengl3.o `test -f 'smooth_opengl3.c' || echo './'`smooth_opengl3.c
smooth_opengl3.c:101: error: redefinition of typedef ‘PFNGLGENBUFFERSPROC’
/usr/X11R6/include/GL/glext.h:5080: error: previous declaration of ‘PFNGLGENBUFFERSPROC’ was here
smooth_opengl3.c:102: error: redefinition of typedef ‘PFNGLBINDBUFFERPROC’
/usr/X11R6/include/GL/glext.h:5078: error: previous declaration of ‘PFNGLBINDBUFFERPROC’ was here
smooth_opengl3.c:103: error: redefinition of typedef ‘PFNGLBUFFERDATAPROC’
/usr/X11R6/include/GL/glext.h:5082: error: previous declaration of ‘PFNGLBUFFERDATAPROC’ was here
smooth_opengl3.c:104: error: redefinition of typedef ‘PFNGLCREATESHADERPROC’
/usr/X11R6/include/GL/glext.h:5197: error: previous declaration of ‘PFNGLCREATESHADERPROC’ was here
smooth_opengl3.c:105: error: redefinition of typedef ‘PFNGLSHADERSOURCEPROC’
/usr/X11R6/include/GL/glext.h:5222: error: previous declaration of ‘PFNGLSHADERSOURCEPROC’ was here
smooth_opengl3.c:106: error: redefinition of typedef ‘PFNGLCOMPILESHADERPROC’
/usr/X11R6/include/GL/glext.h:5195: error: previous declaration of ‘PFNGLCOMPILESHADERPROC’ was here
smooth_opengl3.c:107: error: redefinition of typedef ‘PFNGLCREATEPROGRAMPROC’
/usr/X11R6/include/GL/glext.h:5196: error: previous declaration of ‘PFNGLCREATEPROGRAMPROC’ was here
smooth_opengl3.c:108: error: redefinition of typedef ‘PFNGLATTACHSHADERPROC’
/usr/X11R6/include/GL/glext.h:5193: error: previous declaration of ‘PFNGLATTACHSHADERPROC’ was here
smooth_opengl3.c:109: error: redefinition of typedef ‘PFNGLLINKPROGRAMPROC’
/usr/X11R6/include/GL/glext.h:5221: error: previous declaration of ‘PFNGLLINKPROGRAMPROC’ was here
smooth_opengl3.c:110: error: redefinition of typedef ‘PFNGLUSEPROGRAMPROC’
/usr/X11R6/include/GL/glext.h:5223: error: previous declaration of ‘PFNGLUSEPROGRAMPROC’ was here
smooth_opengl3.c:111: error: redefinition of typedef ‘PFNGLGETSHADERIVPROC’
/usr/X11R6/include/GL/glext.h:5209: error: previous declaration of ‘PFNGLGETSHADERIVPROC’ was here
smooth_opengl3.c:112: error: redefinition of typedef ‘PFNGLGETSHADERINFOLOGPROC’
/usr/X11R6/include/GL/glext.h:5210: error: previous declaration of ‘PFNGLGETSHADERINFOLOGPROC’ was here
smooth_opengl3.c:113: error: redefinition of typedef ‘PFNGLGETPROGRAMIVPROC’
/usr/X11R6/include/GL/glext.h:5207: error: previous declaration of ‘PFNGLGETPROGRAMIVPROC’ was here
smooth_opengl3.c:114: error: redefinition of typedef ‘PFNGLGETPROGRAMINFOLOGPROC’
/usr/X11R6/include/GL/glext.h:5208: error: previous declaration of ‘PFNGLGETPROGRAMINFOLOGPROC’ was here
smooth_opengl3.c:115: error: redefinition of typedef ‘PFNGLGETATTRIBLOCATIONPROC’
/usr/X11R6/include/GL/glext.h:5206: error: previous declaration of ‘PFNGLGETATTRIBLOCATIONPROC’ was here
smooth_opengl3.c:116: error: redefinition of typedef ‘PFNGLVERTEXATTRIBPOINTERPROC’
/usr/X11R6/include/GL/glext.h:5280: error: previous declaration of ‘PFNGLVERTEXATTRIBPOINTERPROC’ was here
smooth_opengl3.c:117: error: redefinition of typedef ‘PFNGLENABLEVERTEXATTRIBARRAYPROC’
/usr/X11R6/include/GL/glext.h:5202: error: previous declaration of ‘PFNGLENABLEVERTEXATTRIBARRAYPROC’ was here
smooth_opengl3.c:118: error: redefinition of typedef ‘PFNGLGETUNIFORMLOCATIONPROC’
/usr/X11R6/include/GL/glext.h:5212: error: previous declaration of ‘PFNGLGETUNIFORMLOCATIONPROC’ was here
smooth_opengl3.c:119: error: redefinition of typedef ‘PFNGLUNIFORMMATRIX4FVPROC’
/usr/X11R6/include/GL/glext.h:5242: error: previous declaration of ‘PFNGLUNIFORMMATRIX4FVPROC’ was here
make[4]: *** [smooth_opengl3-smooth_opengl3.o] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
This has been documented on the net before, but the solution isn't really all that helpful in this instance. I've also tried swapping it for the GLUT.framwork that comes with OS X, but the examples are using FreeGLUT-specific functions.
XQuartz 2.7.2 swapped to FreeGLUT (2.8.0) instead of the old MesaGLUT. So provided you have OS X version 10.6.3 or later, you can just install XQuartz 2.7.2 or later. See:
http://xquartz.macosforge.org/trac/wiki/X112.7.2
http://lists.apple.com/archives/x11-users/2012/Apr/msg00020.html
It was suggested on Xquartz's mail list, that the freeglut demo is wrong to declare those PFN*PROC twice.
So, by simply commenting out those double-definition from smooth_opengl3.c, the free glut would pass the compilation phase. However, from my experience, it would not run and give some error about the GLSL.
It was also suggested that GLUT framework should be used on Mac OS X.
It´s working for me with the following parameters to configure:
./configure CFLAGS="-I/usr/X11/include/X11/extensions -L/usr/X11/lib" LIBS="-lXrandr -lXxf86vm -lXi" --with-x --x-includes=/usr/X11/include

Resources