Choosing System C library Khem Raj Comcast Embedded Linux - - PowerPoint PPT Presentation

choosing system c library
SMART_READER_LITE
LIVE PREVIEW

Choosing System C library Khem Raj Comcast Embedded Linux - - PowerPoint PPT Presentation

Choosing System C library Khem Raj Comcast Embedded Linux Conference Europe 2014 Dsseldorf Germany Introduction God defined C standard library everything else is creation of man Introduction Standard library for C language


slide-1
SLIDE 1

Choosing System C library

Khem Raj Comcast

Embedded Linux Conference Europe 2014 Düsseldorf Germany

slide-2
SLIDE 2

Introduction

“God defined C standard library everything else is creation of man”

slide-3
SLIDE 3

Introduction

  • Standard library for C language
  • Provides primitives for OS service
  • Hosted/freestanding
  • String manipulations
  • Types
  • I/O
  • Memory
  • APIs
slide-4
SLIDE 4

Linux Implementations

  • GNU C library (glibc)
  • uClibc
  • eglibc

– Now merged into glibc

  • Dietlibc
  • Klibc
  • Musl
  • bionic
slide-5
SLIDE 5

Multiple C library FAQs

  • Can I have multiple C libraries side by side ?
  • Can programs compiled with glibc run on

uclibc or vice versa ?

  • Are they functional compatible ?
  • Do I need to choose one over other if I am

doing real time Linux?

  • I have a baremetal application what libc
  • ptions do I have ?
slide-6
SLIDE 6

Posix Compliance

  • Posix specifies more than ISO C
  • Varying degree of compliance
slide-7
SLIDE 7

What matters to you ?

  • Code Size
  • Functionality
  • Interoperability
  • Licensing
  • Backward Compatibility
  • Variety of architecture support
  • Dynamic Linking
  • Build system
slide-8
SLIDE 8

Codesize

  • Dietlibc/klibc

– Used in really small setup e.g. initramfs

  • Bionic

– Small linked into every process

  • uClibc

– Configurable

  • Size can be really small at the expense of functionality
  • Eglibc

– Has option groups can be ( < 1M )

slide-9
SLIDE 9

License

  • Bionic – BSD/Apache-2.0
  • Musl - MIT
  • Uclibc – LGPL-2.1
  • Eglibc/Glibc – LGPL-2.1 Assigned to FSF
  • Dietlibc – GPLv2
  • Klibc – GPLv2
  • Newlib – some parts are GPLv3
slide-10
SLIDE 10

Compliance

  • Musl strives for ISO/C and POSIX compliance
slide-11
SLIDE 11

No-mmu

  • uClibc supported No-mmu
slide-12
SLIDE 12

Distributions

  • Glibc is used in majority of distribution

– Fedora-like, RHEL, Debian-like, SuSE, Gentoo, Archlinux ….

  • Buildroot

– Uclibc and glibc

  • OpenEmbedded

– Uclibc/glibc/musl

  • Alpine

– Uclibc/musl

slide-13
SLIDE 13

Performance

  • Glibc has architecture optimized str/mem

routines

slide-14
SLIDE 14

Stability

  • Stable ABI – glibc,musl
  • Backward compatibility – glibc, musl
  • Symbol versioning – glibc
  • LSB compliance - glibc
slide-15
SLIDE 15

Features

  • C99 Math library – glibc and musl
  • Posix threads – uclibc/glibc/musl
  • C11 TLS – uclibc/glibc/musl
  • Wide chars – uclibc/glibc/musl
  • Profiling – glibc
  • Debugging Features – glibc
  • Zoneinfo – glibc/musl
slide-16
SLIDE 16

Features

  • Stack smashing Protection – uclibc/glibc/musl
  • Heap corruption Detection – musl/glibc
slide-17
SLIDE 17

CPU Architectures

  • Glibc supports the widest range

– ARM/MIPS/x86/SH/PPC/SPARC/Alpha/IA64/Micro blaze/s390

  • Uclibc does support most of above except few.
  • Eg. S390, x32 but then it supports ARC, AVR32

..

  • Musl is getting architecture parity
  • Bionic arm/x86/mips