Can't create a linkable library with XMAKE Topic is solved

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
User avatar
BEBDigitalAudio
Experienced Member
Posts: 80
Joined: Thu Nov 11, 2010 7:45 pm

Can't create a linkable library with XMAKE

Postby BEBDigitalAudio » Tue Sep 08, 2020 9:02 am

Hello everybody,

I am trying to compile a proprietary library (I don't want to distribute the source to the final user, only a library) following instructions from X4954A document.

The document itself is a bit outdated, so I changed declarations like MODULE_XCC_XC_FLAGS to LIB_XCC_XC_FLAGS. The library itself works like a charm under xTimeComposer 14.4.3 (we use it in all of our products) when included in a project, but I can't compile it as an independent library.

I have created a makefile as recommended in the document

LIBRARY = LIB_KISSBOXV4

LIB_XCC_XC_FLAGS = $(XCC_XC_FLAGS)
LIB_XCC_FLAGS = $(XCC_FLAGS) -g -O3

# The following specifies the dependencies of the module. When an application
# includes a module it will also include all its dependencies.
# DEPENDENT_MODULES =

VERSION = 1.0.0


When I launch xmake on this makefile, I get multiple "undeclared identifiers" related to the physical target (for example, "use of undeclared identifier 'tile')

I noticed them that the compiler compiles for the wrong target : it compiles for XS1B, while my processor is a XCore200

I have then placed my XN file in the makefile directory but now, I get following errors "xcc: error: conflicting arch and target specified 0 1". So it seems that the compiler wants absolutely to compile for the XS1B (or anything else), and not for my real target. I have tried to add the following line in the module definition file (our target definition is cpu_v4.xn)

TARGET = CPU_V4

but it does not change anything, the compiler still complains about conflict between arch and target

Does anybody know how I should specify my target/architecture in the makefile or the module_build_info file, so the library can be compiled for my physical target ?
(Or maybe if somebody knows if XMOS has updated document X4954A to include XCore200 processors and xTimeComposer

Thanks

Benoit
View Solution
User avatar
mon2
XCore Legend
Posts: 1809
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Tue Sep 08, 2020 10:08 am

Start with a fresh workspace -> build a fresh project -> select a kit that matches your CPU or enable the check box to display the CPU list and match it to your target cpu.

Allow the wizard to finish this empty project.

Now review the details of the make file and XN file for your custom project.

Another method is to repeat the above but import a working project for the xcore-200 series -> build the project as imported -> toolchain will import and update all dependencies usually automatically -> after the build is successful, proceed to go back and modify the target CPU using the toolchain method and recompile again. If it all builds, steal the makefile and XN file for your target CPU.
User avatar
BEBDigitalAudio
Experienced Member
Posts: 80
Joined: Thu Nov 11, 2010 7:45 pm

Postby BEBDigitalAudio » Wed Sep 09, 2020 6:51 am

mon2 wrote:
Tue Sep 08, 2020 10:08 am
Start with a fresh workspace -> build a fresh project -> select a kit that matches your CPU or enable the check box to display the CPU list and match it to your target cpu.

Allow the wizard to finish this empty project.

Now review the details of the make file and XN file for your custom project.

Another method is to repeat the above but import a working project for the xcore-200 series -> build the project as imported -> toolchain will import and update all dependencies usually automatically -> after the build is successful, proceed to go back and modify the target CPU using the toolchain method and recompile again. If it all builds, steal the makefile and XN file for your target CPU.
Hi mon2,

thank you for your answer, but this is not what I want to achieve. What you describe generates a .xe executable for a given target, it does not generate a linkable library.
When you create library from a workspace, it is not compiled as a linkable one, it is compiled by a "top" project when needed.

As explained in X4954A document from XMOS, a linkable libray (a library that you can distribute without the sources) can only be compiled from command line, it can not be compiled from xTimeComposer (xTimeComposer stops immediately when it finds a makefile starting with LIBRARY= line, it reports "** Module only - only builds as part of application **")

Benoit
User avatar
Sebastian
Active Member
Posts: 34
Joined: Wed Jul 20, 2016 9:15 am

Postby Sebastian » Wed Sep 09, 2020 10:01 am

Hi Benoit,

maybe this post could help you.
viewtopic.php?f=47&t=7736&p=36904&hilit ... ian#p36904
[create binary lib for xcore-200]

best,
Sebastian
User avatar
mon2
XCore Legend
Posts: 1809
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Wed Sep 09, 2020 11:42 am

I think you missed the point. The process shown is to assist you to debug your broken makefile. Your current makefile is building for the wrong Xmos target and hence raising the architecture mismatch. Using the toolchain, you can allow for the wizard to populate the keywords that are incorrect in your current makefile.

Using this procedure, you can fix your own makefile and build the library for your target. As you change the target with the toolchain, observe how the target keywords also change. Use only these values and you can fix your broken makefile.
User avatar
BEBDigitalAudio
Experienced Member
Posts: 80
Joined: Thu Nov 11, 2010 7:45 pm

Postby BEBDigitalAudio » Fri Sep 11, 2020 10:21 am

mon2 wrote:
Wed Sep 09, 2020 11:42 am
I think you missed the point. The process shown is to assist you to debug your broken makefile. Your current makefile is building for the wrong Xmos target and hence raising the architecture mismatch. Using the toolchain, you can allow for the wizard to populate the keywords that are incorrect in your current makefile.

Using this procedure, you can fix your own makefile and build the library for your target. As you change the target with the toolchain, observe how the target keywords also change. Use only these values and you can fix your broken makefile.
Hi Mon2,

I understand what you intend to do with this procedure, but this is something I already tried. And it does not solve the problem at all.

Here is the situation I reach depending on the approach I use :

Approach 1 : X4954A document from XMOS clearly explain what is needed in the makefile to create a library. However, this leads to a library compiled for XS1B target (but it generates a library !)
Approach 2 : if I use the makefile generator as you propose, the compiler produces a binary for the correct target (XS2) but this is not a library, it is a XE file. And moreover, in that case, compiler complains that it lacks a main(), which is normal as the makefile generator is designed to create executables. If I remove the lines generated by the makefile generator to produce a .xe file, then I go back exactly to the situation of approach 1.

It seems that the toolchain has a bug, as it ignores simply the target definition when it deals with a library. As far as I can see, XMAKE sticks to XS1B by default when it compiles a library (the feeling I have is that this is something that is not used, as nobody extern to XMOS provides libraries without the sources)

Benoit
User avatar
BEBDigitalAudio
Experienced Member
Posts: 80
Joined: Thu Nov 11, 2010 7:45 pm

Postby BEBDigitalAudio » Fri Sep 11, 2020 10:24 am

Sebastian wrote:
Wed Sep 09, 2020 10:01 am
Hi Benoit,

maybe this post could help you.
viewtopic.php?f=47&t=7736&p=36904&hilit ... ian#p36904
[create binary lib for xcore-200]

best,
Sebastian
Hi Sebastian,

thank you for finding this °-)

It seems somebody else got the same problem... and yes, it seems to work !
I have just made a quick test, and after tweaking the XMOS makefiles, my library is now compiled for a XS2A target (I don't care if I can't generate for XS1B, as we switched to XS2 since 2 years and we are not producing anymore the previous generation based on XS1)

Benoit

Who is online

Users browsing this forum: No registered users and 4 guests