Problems with fc-arch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

While doing general maintenance I ended up cleaning all the different source 
files we generate during build (fclang.h, fccase.h, fcglyhnames.h, fcarch.h). 
  Of those four, the first three are static and I decide to ship in the 
tarball.  This should make cross-compiling a tad bit easier.

I figured that configure.in already tries to find CC_FOR_BUILD and 
EXEEXT_FOR_BUILD.  And surprisingly, those are used to compile and run 
fc-arch.c, which means the architecture detected will be the build 
architecture, not the target!

I'm guessing that the end result have been that all the embedded companies 
commpiling fontconfig for ARM have been getting cache files with an x86 
extension, but since those caches were not shared, this didn't cause any problem.

To fix this, I'm thinking about getting rid of fc-arch.c and move the logic 
into a compile-time header file.  Something like:


#define CHECK_ARCH(arch, sizeof_Align, sizeof_char, sizeof_int, sizeof_long) \
	(sizeof (FcAlign) == sizeof_Align && \
	 sizeof (char) == sizeof_char && \
	 sizeof (int) == sizeof_int && \
	 sizeof (long) == sizeof_long) ? (arch)

#define FC_ARCHITECTURE (\
	CHECK_ARCH("x86",    4,1,4,4) : \
	CHECK_ARCH("x86-64", 8,1,4,8) : \
	"unknown" )

This should work fine.  The only problem is, it's not very friendly to new 
architectures:

   1) falls back to "unknown".  Can't err.  Maybe if I use something like:

extern char *unknown_architecture;
#define FC_ARCHITECTURE (\
	CHECK_ARCH("x86",    4,1,4,4) : \
	CHECK_ARCH("x86-64", 8,1,4,8) : \
	unknown_architecture )

it may fail at link time.  But may also fail if compiled without 
optimizations?  Donno.



Another option is to move all the logic to configure.  AC_CHECK_SIZEOF these 
days can find sizeof(type) even when cross-compiling (it binary searches!). 
In fact, there's even AC_COMPUTE_INT() which gets the number out to a shell 
variable.  So we can find all the sizes we use and do the arch-finding magic 
in configure.  This has the following benefits:

   - It errs during configure if arch is unknown, and will print instructions 
and the signature to add.  Good.

   - Arch can be overridden using a configure argument.  Good.

   - We can use the arch name in Makefile.am.  For example, I also have a plan 
to replace fc-cache with a shell script that will run any file executable file 
in '$(bindir)/fc-cache.d/'.  And then install the actual binary of fc-cache as 
'$(bindir)/fc-cache.d/fc-cache-$(ARCH)'.  This way, on multi-arch machines, 
fc-cache which will do the right thing, which is generating caches for both archs.

   - The configure checks may be a bit slow.

   - The downside of this scheme is that it's autotools-based.  But then 
again, people compiling using other tools already have to define 
FC_ARCHITECTURE to something.  They can keep doing that.


Unless someone shouts, I think I'm going to implement the configure scheme, 
ship the other generated files, and get rid of CC_FOR_BUILD stuff.

behdad
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux