Linus關於核心標頭檔案與核心原始碼關係的論述(轉)
Linus關於核心標頭檔案與核心原始碼關係的論述(轉)[@more@]
CODE:
From: Linus Torvalds (torvalds@transmeta.com)
Date: Thu Jul 27 2000 - 02:39:51 EST In article Boszormenyi Zoltan > >/usr/include/asm is a symlink to /usr/src/linux/include/asm, as in the >original distribution but /usr/src/linux is a 2.4.0-testX tree. >With a 2.2.X source tree, it does not produce any warning. I've asked glibc maintainers to stop the symlink insanity for the last few years now, but it doesn't seem to happen. Basically, that symlink should not be a symlink. It's a symlink for historical reasons, none of them very good any more (and haven't been for a long time), and it's a disaster unless you want to be a C library developer. Which not very many people want to be. The fact is, that the header files should match the library you link against, not the kernel you run on. Think about it a bit.. Imagine that the kernel introduces a new "struct X", and maintains binary backwards compatibility by having an old system call in the old place that gets passed a pointer to "struct old_X". It's all compatible, because binaries compiled for the old kernel will still continue to run - they'll use the same old interfaces they are still used to, and they obviously do not know about the new ones. Now, if you start mixing a new kernel header file with an old binary "glibc", you get into trouble. The new kernel header file will use the _new_ "struct X", because it will assume that anybody compiling against it is after the new-and-improved interfaces that the new kernel provides. But then you link that program (with the new "struct X") to the binary library object archives that were compiled with the old header files, that use the old "struct old_X" (which _used_ to be X), and that use the old system call entry-points that have the compatibility stuff to take "struct old_X". Boom! Do you see the disconnect? In short, the _only_ people who should update their /usr/include/linux tree are the people who actually make library releases and compile their own glibc, because if they want to take advantaged of new kernel features they need those new definitions. That way there is never any conflict between the library and the headers, and you never get warnings like the above.. >Mr. Ulrich Drepper (one of the glibc/gcc guys) gave me a standard >"don't use kernel headers directly" answer. But neither gcc.c, >neither the above small program use kernel headers. I suppose he >referred to /usr/include/linux/* as (I think) he did not understand me. No. He really meant that you should not use the kernel headers: you should use the headers that glibc came with. It is probably a redhat bug that those headers were a symbolic link. I would suggest that people who compile new kernels should: - NOT do so in /usr/src. Leave whatever kernel (probably only the header files) that the distribution came with there, but don't touch it. - compile the kernel in their own home directory, as their very own selves. No need to be root to compile the kernel. You need to be root to _install_ the kernel, but that's different. - not have a single symbolic link in sight (except the one that the kernel build itself sets up, namely the "linux/include/asm" symlink that is only used for the internal kernel compile itself) And yes, this is what I do. My /usr/src/linux still has the old 2.2.13 header files, even though I haven't run a 2.2.13 kernel in a _loong_ time. But those headers were what glibc was compiled against, so those headers are what matches the library object files. And this is actually what has been the suggested environment for at least the last five years. I don't know why the symlink business keeps on living on, like a bad zombie. Pretty much every distribution still has that broken symlink, and people still remember that the linux sources should go into "/usr/src/linux" even though that hasn't been true in a _loong_ time. Is there some documentation file that I've not updated and that people are slavishly following outdated information in? I don't read the documentation myself, so I'd never notice ;) Linus 來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617542/viewspace-960411/,如需轉載,請註明出處,否則將追究法律責任。
上一篇:
硬碟主引導扇區的結構及功能全面釋疑(轉)
請登入後發表評論
登入
全部評論
|
相關文章
- 關於C++的標頭檔案C++
- 8.14 Linux核心中的標頭檔案Linux
- gcc 標頭檔案依賴關係 分析工具GC
- C語言關於標頭檔案的使用C語言
- CentOS升級核心與容器執行時核心引數的關係CentOS
- 關於vim看linux 核心原始碼時的程式碼補全Linux原始碼
- android版本與linux核心版本對應關係AndroidLinux
- 關於QT的標頭檔案相互包含的問題QT
- 關於hive核心Hive
- 關於Spring Cloud的核心特性SpringCloud
- Linus Torvalds 彬彬有禮的指出糟糕的核心程式碼
- 關於git的基本核心操作總結Git
- 海量文字中挖掘人物關聯關係核心技術介紹
- 鴻蒙輕核心原始碼分析:檔案系統LittleFS鴻蒙原始碼
- 【核心檔案系統】原始碼閱讀stat.h原始碼
- [轉帖]Redis相關的核心引數解釋與設定Redis
- 快速上手Linux核心命令(四):檔案內容相關命令Linux
- 關於MySQL核心,一定要知道的!MySql
- MongoDB與MMAPV1相關的資料檔案簡述MongoDB
- C++標準庫中檔案流類的繼承關係C++繼承
- 一次關於關係抽取(RE)綜述調研的交流心得
- gin 原始碼閱讀(1) - gin 與 net/http 的關係原始碼HTTP
- 關係錶轉dooris 的java 指令碼Java指令碼
- Linux核心檔案Linux
- 有標底評標與無標底評標的關係
- 一個關於wait/notify與鎖關係的探究AI
- 部落格園中隨筆、文章、日記、評論、標籤、合集、連結、相簿、檔案的關係
- 關於Linux核心自帶GPIO LED控制Linux
- 關於 Service Worker 和 Web 應用對應關係的討論Web
- 3.1.2.1 關於資料庫初始化引數檔案和啟動的關係資料庫
- Linux Shell檔案之間的包含關係Linux
- PostgreSQL的表檔案以及TOAST表檔案對應關係SQLAST
- [轉帖]Linux核心原始碼分析分享專題Linux原始碼
- 關於檔案的open方法
- quotes屬性與<q>標籤關係
- JVMTI Attach機制與核心原始碼分析JVM原始碼
- Linux 核心相關命令Linux
- C++自學34:原始檔與標頭檔案(pragma/ifndef/endif/ifdef)C++
- 關於軟體測試的7個核心問題